reverted all src changes from rev95 commit (because all old work was just removed)

git-svn-id: https://clonekeenplus.svn.sourceforge.net/svnroot/clonekeenplus/cgenius/trunk@107 4df4b0f3-56ce-47cb-b001-ed939b7d65a6
This commit is contained in:
albertzeyer
2009-07-22 21:50:13 +00:00
parent ef725f8581
commit 23ef380643
50 changed files with 5547 additions and 5582 deletions

View File

@@ -128,7 +128,7 @@ void CCredits::Render(stCloneKeenPlus *pCKP)
for(int j=0 ; j<51 ; j++)
if(scrolly+(j<<3) > -8 && scrolly+(j<<3) < 200)
g_pGraphics->sb_font_draw_inverse( (unsigned char*) scrolltext[j], mid[j], scrolly+(j<<3));
g_pGraphics->sb_font_draw_inverse( scrolltext[j], mid[j], scrolly+(j<<3));
if( g_pInput->getPressedAnyCommand() )
{

View File

@@ -77,10 +77,9 @@ void CDialog::addSeparator(void)
addOptionText("");
}
void CDialog::addOptionText(const char *text)
void CDialog::addOptionText(const std::string& text)
{
char buf[TEXT_LENGTH];
memset(buf,0,TEXT_LENGTH);
std::string buf;
// This algorithm is similar to one pointer session and
// list implementation. TextList is the head.
if(OptionTextList == NULL)
@@ -88,22 +87,21 @@ void CDialog::addOptionText(const char *text)
OptionTextList = new stTextList;
OptionTextList->nextElement = NULL;
memset(OptionTextList->text,0,TEXT_LENGTH);
OptionTextList->text = "";
strcpy(buf,text);
buf = text;
unsigned int length;
length = strlen(buf);
size_t length = buf.length();
// before the text is copied, check if that string is too long.
if(length > w-4)
{
copy(text,text+w-7,OptionTextList->text);
strcat(OptionTextList->text,"...");
OptionTextList->text = text.substr(0, w-7);
OptionTextList->text += "...";
}
else
{
strcpy(OptionTextList->text,text);
OptionTextList->text = text;
}
number_of_options = 1;
@@ -124,41 +122,41 @@ void CDialog::addOptionText(const char *text)
curTextList = (stTextList*) curTextList->nextElement;
memset(curTextList->text,0, TEXT_LENGTH);
curTextList->text = "";
number_of_options++;
strcpy(buf,text);
buf = text;
unsigned int length;
length = strlen(buf);
size_t length = buf.length();
// before the text is copied, check if that string is too long.
if(length > w-4)
{
copy(text,text+w-7,curTextList->text);
strcat(curTextList->text,"...");
curTextList->text = text.substr(0, w-7);
curTextList->text += "...";
}
else
{
strcpy(curTextList->text,text);
curTextList->text = text;
}
curTextList->nextElement = NULL;
}
}
void CDialog::setOptionText(unsigned int pos, const char *text)
void CDialog::setOptionText(unsigned int pos, const std::string& text)
{
unsigned int i;
stTextList *curTextList;
stTextList *curTextList = OptionTextList;
curTextList = OptionTextList;
for(i=0 ; i<pos ; i++)
curTextList = (stTextList*) curTextList->nextElement;
memset(curTextList->text,0,TEXT_LENGTH);
strcpy(curTextList->text,text);
for(i=0 ; i<pos ; i++) {
if(!curTextList)
// TODO: print error
return;
curTextList = curTextList->nextElement;
}
curTextList->text = text;
}
void CDialog::setDimensions(int rectx, int recty, int rectw, int recth)
@@ -197,7 +195,7 @@ void CDialog::renderDialog()
while(curTextList != NULL)
{
g_pGraphics->sb_font_draw((unsigned char*)(curTextList->text), (x+3)<<3, (y+i+1)<<3);
g_pGraphics->sb_font_draw(curTextList->text, (x+3)<<3, (y+i+1)<<3);
curTextList = (stTextList*) curTextList->nextElement;
i++;
if(i >= h-2)
@@ -287,7 +285,7 @@ void CDialog::renderOpenDialogAnimation(int x,int y, int w, int h)
isanimated = false;
}
char *CDialog::getOptionString(unsigned int pos)
std::string CDialog::getOptionString(unsigned int pos)
{
unsigned int i;
stTextList *curTextList;
@@ -327,7 +325,7 @@ bool CDialog::setNextSelection()
int i=0;
if(selection+1 < number_of_options)
{
while(strcmp(getOptionString(selection+i+1),"") == 0)
while(getOptionString(selection+i+1) == "")
i++;
selection += i;
@@ -343,7 +341,7 @@ bool CDialog::setPrevSelection()
int i=0;
if(selection-1 > 0)
{
while(strcmp(getOptionString(selection-i-1),"") == 0)
while(getOptionString(selection-i-1) == "")
i++;
selection -= i;

View File

@@ -8,13 +8,13 @@
#ifndef CDIALOG_H_
#define CDIALOG_H_
#define TEXT_LENGTH 256
#include <string>
typedef struct stTextList
struct stTextList
{
char text[TEXT_LENGTH];
void *nextElement;
}stTextList;
std::string text;
stTextList *nextElement;
};
class CDialog {
public:
@@ -25,8 +25,8 @@ public:
void drawDialogbox(int x1, int y1, int w, int h);
void setDimensions(int rectx, int recty, int rectw, int recth);
void addOptionText(const char *text);
void setOptionText(unsigned int pos, const char *text);
void addOptionText(const std::string& text);
void setOptionText(unsigned int pos, const std::string& text);
void addSeparator(void);
bool setSelection(int value);
@@ -34,7 +34,7 @@ public:
bool setPrevSelection();
int getSelection(void);
char *getOptionString(unsigned int pos);
std::string getOptionString(unsigned int pos);
void renderOpenDialogAnimation(int x,int y, int w, int h);
void animateDialogBox(bool value);

View File

@@ -12,11 +12,14 @@
#endif
#include <fstream>
#include <vector>
#include "../StringUtils.h"
using namespace std;
CEGAGraphics::CEGAGraphics(short episode, const char *path) {
CEGAGraphics::CEGAGraphics(short episode, const std::string& path) {
m_episode = episode;
strcpy(m_path, path);
m_path = path;
// EGAHEAD Structure
LatchPlaneSize = 0;
@@ -51,15 +54,15 @@ CEGAGraphics::~CEGAGraphics() {
bool CEGAGraphics::loadData()
{
char buf[256];
std::string buf;
vector<char> databuf;
chdir("data"); // TODO: You must be able to use another directory
if(m_path[0] == 0)
sprintf(buf,"egahead.ck%hd",m_episode);
if(m_path == "")
buf = "egahead.ck" + itoa(m_episode);
else
sprintf(buf,"%s/egahead.ck%hd",m_path,m_episode);
ifstream HeadFile(buf,ios::binary);
buf = m_path + "/egahead.ck" + itoa(m_episode);
std::ifstream HeadFile(buf.c_str(),ios::binary);
if(!HeadFile)
return false;
@@ -72,9 +75,7 @@ bool CEGAGraphics::loadData()
}
HeadFile.close();
char *data;
data = new char[databuf.size()];
char *data = new char[databuf.size()];
memcpy(data, &databuf[0], databuf.size());
// Now copy the data to the EGAHEAD Structure
@@ -108,10 +109,10 @@ bool CEGAGraphics::loadData()
m_Latch->loadHead(data);
if(m_path[0] == 0)
sprintf(buf,"egalatch.ck%hd",m_episode);
if(m_path == "")
buf = "egalatch.ck" + itoa(m_episode);
else
sprintf(buf,"%s/egalatch.ck%hd",m_path,m_episode);
buf = m_path + "/egalatch.ck" + itoa(m_episode);
m_Latch->loadData(buf,(compressed>>1)); // The second bit tells, if latch is compressed.
@@ -121,16 +122,14 @@ bool CEGAGraphics::loadData()
SpriteLocation);
m_Sprit->loadHead(data);
if(m_path[0] == 0)
sprintf(buf,"egasprit.ck%hd",m_episode);
if(m_path == "")
buf = "egasprit.ck" + itoa(m_episode);
else
sprintf(buf,"%s/egasprit.ck%hd",m_path,m_episode);
buf = m_path + "/egasprit.ck" + itoa(m_episode);
m_Sprit->loadData(buf,(compressed>>1));
chdir("../");
delete [] data;
return true;
}

View File

@@ -14,12 +14,13 @@
#ifndef CEGAGRAPHICS_H_
#define CEGAGRAPHICS_H_
#include <string>
#include "CEGALatch.h"
#include "CEGASprit.h"
class CEGAGraphics {
public:
CEGAGraphics(short episode, const char *path);
CEGAGraphics(short episode, const std::string& path);
virtual ~CEGAGraphics();
bool loadData();
@@ -28,7 +29,7 @@ public:
private:
short m_episode;
char m_path[256];
std::string m_path;
// Part of the EGAHEAD Data Structure
// Section 1:

View File

@@ -65,12 +65,11 @@ bool CEGALatch::loadHead( char *data )
return true;
}
bool CEGALatch::loadData(const char *filename, bool compresseddata)
bool CEGALatch::loadData(const std::string& filename, bool compresseddata)
{
FILE* latchfile;
char *RawData;
latchfile = fopen(filename,"rb");
FILE* latchfile = fopen(filename.c_str(),"rb");
if(!latchfile)
return false;

View File

@@ -8,7 +8,8 @@
#ifndef CEGALATCH_H_
#define CEGALATCH_H_
#include <SDL/SDL.h>
#include <SDL.h>
#include <string>
class CEGALatch {
public:
@@ -25,7 +26,7 @@ public:
virtual ~CEGALatch();
bool loadHead(char *data );
bool loadData(const char *filename, bool compresseddata);
bool loadData(const std::string& filename, bool compresseddata);
char *RawData;

View File

@@ -71,12 +71,11 @@ bool CEGASprit::loadHead(char *data)
return true;
}
bool CEGASprit::loadData(const char *filename, bool compresseddata)
bool CEGASprit::loadData(const std::string& filename, bool compresseddata)
{
FILE* latchfile;
char *RawData;
latchfile = fopen(filename,"rb");
FILE* latchfile = fopen(filename.c_str(),"rb");
if(!latchfile)
return false;

View File

@@ -8,6 +8,8 @@
#ifndef CEGASPRIT_H_
#define CEGASPRIT_H_
#include <string>
class CEGASprit {
public:
CEGASprit(int planesize,
@@ -17,7 +19,7 @@ public:
virtual ~CEGASprit();
bool loadHead(char *data);
bool loadData(const char *filename, bool compresseddata);
bool loadData(const std::string& filename, bool compresseddata);
private:
int m_numsprites;

View File

@@ -9,9 +9,7 @@
#include <fstream>
#include <string>
using namespace std;
#include <string.h>
#include <cstring>
#include "../keen.h"
#include "../include/menu.h"
@@ -20,10 +18,14 @@ using namespace std;
#include "../sdl/CInput.h"
#include "../sdl/CTimer.h"
#include "../CGraphics.h"
#include "../StringUtils.h"
#define HIGHSCORETABLE_X 1344
#define HIGHSCORETABLE_Y 32
using namespace std;
CHighScores::CHighScores(stCloneKeenPlus *poutsideCKP) {
// Set default Scores
strcpy(Name[0],"Gerstrong");
@@ -124,8 +126,8 @@ char CHighScores::showHighScore(void)
for( i=0 ; i<7 ; i++ )
{
g_pGraphics->sb_color_font_draw((unsigned char*) Name[i],40,64+(i<<4),4,7);
g_pGraphics->sb_color_font_draw((unsigned char*) Score[i],200-(strlen(Score[i])<<3),64+(i<<4),4,7);
g_pGraphics->sb_color_font_draw(Name[i],40,64+(i<<4),4,7);
g_pGraphics->sb_color_font_draw(Score[i],200-(strlen(Score[i])<<3),64+(i<<4),4,7);
if(Extra[i][0] == true)
g_pGraphics->drawTile(32,90+(i<<4),ItemTiles[0]);
if(Extra[i][1] == true)
@@ -140,19 +142,19 @@ char CHighScores::showHighScore(void)
{
for( i=0 ; i<7 ; i++ )
{
char buf[2];
g_pGraphics->sb_color_font_draw((unsigned char*) Name[i],40,64+(i<<4),4,7);
g_pGraphics->sb_color_font_draw((unsigned char*) Score[i],200-(strlen(Score[i])<<3),64+(i<<4),4,7);
sprintf(buf,"%d",Cities[i]);
g_pGraphics->sb_color_font_draw((unsigned char*) buf,250,64+(i<<4),4,7);
std::string buf;
g_pGraphics->sb_color_font_draw(Name[i],40,64+(i<<4),4,7);
g_pGraphics->sb_color_font_draw(Score[i],200-(strlen(Score[i])<<3),64+(i<<4),4,7);
buf = itoa(Cities[i]);
g_pGraphics->sb_color_font_draw(buf,250,64+(i<<4),4,7);
}
}
else
{
for( i=0 ; i<7 ; i++ )
{
g_pGraphics->sb_color_font_draw((unsigned char*) Name[i],40,64+(i<<4),4,7);
g_pGraphics->sb_color_font_draw((unsigned char*) Score[i],200-(strlen(Score[i])<<3),64+(i<<4),4,7);
g_pGraphics->sb_color_font_draw(Name[i],40,64+(i<<4),4,7);
g_pGraphics->sb_color_font_draw(Score[i],200-(strlen(Score[i])<<3),64+(i<<4),4,7);
}
}
@@ -245,19 +247,19 @@ char CHighScores::writeHighScore(int points, bool *extras, int cities)
{
for( i=0 ; i<7 ; i++ )
{
char buf[2];
g_pGraphics->sb_color_font_draw((unsigned char*) Name[i],40,64+(i<<4),4,7);
g_pGraphics->sb_color_font_draw((unsigned char*) Score[i],200-(strlen(Score[i])<<3),64+(i<<4),4,7);
sprintf(buf,"%d",Cities[i]);
g_pGraphics->sb_color_font_draw((unsigned char*) buf,250,64+(i<<4),4,7);
std::string buf;
g_pGraphics->sb_color_font_draw(Name[i],40,64+(i<<4),4,7);
g_pGraphics->sb_color_font_draw(Score[i],200-(strlen(Score[i])<<3),64+(i<<4),4,7);
buf = itoa(Cities[i]);
g_pGraphics->sb_color_font_draw(buf,250,64+(i<<4),4,7);
}
}
else
{
for( i=0 ; i<7 ; i++ )
{
g_pGraphics->sb_color_font_draw((unsigned char*) Name[i],40,64+(i<<4),4,7);
g_pGraphics->sb_color_font_draw((unsigned char*) Score[i],200-(strlen(Score[i])<<3),64+(i<<4),4,7);
g_pGraphics->sb_color_font_draw(Name[i],40,64+(i<<4),4,7);
g_pGraphics->sb_color_font_draw(Score[i],200-(strlen(Score[i])<<3),64+(i<<4),4,7);
}
}
@@ -311,7 +313,7 @@ char CHighScores::writeHighScore(int points, bool *extras, int cities)
if(g_pInput->getPressedKey(KBCKSPCE) && (WrittenName.length() > 0))
{
memset(buf,0,256);
g_pGraphics->sb_color_font_draw((unsigned char*) " ",40,64+(place<<4),4,7);
g_pGraphics->sb_color_font_draw(" ",40,64+(place<<4),4,7);
WrittenName.erase(WrittenName.length()-1);
WrittenName.copy(buf,WrittenName.length(),0);
memset(Name[place],0,16);
@@ -329,10 +331,10 @@ char CHighScores::writeHighScore(int points, bool *extras, int cities)
for( i=0 ; i<7 ; i++ )
{
if(i != place)
g_pGraphics->sb_color_font_draw((unsigned char*) Name[i],40,64+(i<<4),4,7);
g_pGraphics->sb_color_font_draw(Name[i],40,64+(i<<4),4,7);
else
g_pGraphics->sb_color_font_draw((unsigned char*) buf,40,64+(i<<4),4,7);
g_pGraphics->sb_color_font_draw((unsigned char*) Score[i],200-(strlen(Score[i])<<3),64+(i<<4),4,7);
g_pGraphics->sb_color_font_draw(buf,40,64+(i<<4),4,7);
g_pGraphics->sb_color_font_draw(Score[i],200-(strlen(Score[i])<<3),64+(i<<4),4,7);
if(pCKP->Control.levelcontrol.episode == 1)
{
@@ -364,9 +366,7 @@ char CHighScores::writeHighScore(int points, bool *extras, int cities)
char CHighScores::loadHighScoreTable(void)
{
string sBuf;
char chBuf[256];
sprintf(chBuf,"%d",Episode);
std::string chBuf = itoa(Episode);
sBuf.append("data/");
sBuf.append(DataDirectory);

View File

@@ -8,6 +8,8 @@
#ifndef CHIGHSCORES_H_
#define CHIGHSCORES_H_
#include <string>
class CHighScores {
public:
CHighScores(stCloneKeenPlus *poutsideCKP);
@@ -25,7 +27,7 @@ private:
int ItemTiles[4];
char Episode;
char *DataDirectory;
std::string DataDirectory;
stCloneKeenPlus *pCKP;

View File

@@ -55,7 +55,7 @@ bool CMessages::readData(char *buf, int episode, int version)
// Now read the stuff and store it to a list
for(int pos=offset_start ; pos<offset_end ; pos++)
{
string Text;
std::string Text;
while(buf[pos] != 0)
{
@@ -68,7 +68,7 @@ bool CMessages::readData(char *buf, int episode, int version)
StringList.push_back(Text);
}
list<string> :: iterator i;
std::list<std::string> :: iterator i;
#include <iostream>
for(i=StringList.begin() ; i!=StringList.end() ; i++)

View File

@@ -12,8 +12,6 @@
#include <string>
#include <iostream>
using namespace std;
// TODO: Make the strings a class, but it must read from the exe-files basing on uncompressed buffer
class CMessages {
@@ -25,8 +23,8 @@ public:
char *getString(const char *IDtext);
private:
list<string> StringList;
list<string> StringIDList;
std::list<std::string> StringList;
std::list<std::string> StringIDList;
};
#endif /* CMESSAGES_H_ */