You can subscribe to this list here.
2006 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
(44) |
Aug
(36) |
Sep
(5) |
Oct
|
Nov
(6) |
Dec
(2) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2007 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
(2) |
Sep
|
Oct
|
Nov
|
Dec
(1) |
2008 |
Jan
|
Feb
|
Mar
|
Apr
(87) |
May
(54) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: <dv...@us...> - 2008-04-20 22:08:22
|
Revision: 150 http://dunelegacy.svn.sourceforge.net/dunelegacy/?rev=150&view=rev Author: dvalin Date: 2008-04-20 15:08:19 -0700 (Sun, 20 Apr 2008) Log Message: ----------- merge soundplayer from richie's branch Added Paths: ----------- branches/dunks/include/SoundPlayerClass.h branches/dunks/src/SoundPlayerClass.cpp Added: branches/dunks/include/SoundPlayerClass.h =================================================================== --- branches/dunks/include/SoundPlayerClass.h (rev 0) +++ branches/dunks/include/SoundPlayerClass.h 2008-04-20 22:08:19 UTC (rev 150) @@ -0,0 +1,116 @@ +#ifndef SOUNDPLAYERCLASS_H_INCLUDED +#define SOUNDPLAYERCLASS_H_INCLUDED + +#include <string> +#include <vector> +#include "ResMan.h" +#include "dMath.h" +#include "SDL_mixer.h" +using namespace std; + +//! \enum MUSICTYPE +/*! Types of music available in the game*/ +typedef enum { MUSIC_ATTACK, /*!<Played when at least one of player's units was hit. */ + MUSIC_INTRO, /*!<Background music for intro. */ + MUSIC_LOSE, /*!<Failure screen background music. */ + MUSIC_PEACE, /*!<Played most of the time when the enemy is not attacking. */ + MUSIC_WIN, /*!<Victory screen background music.. */ + MUSIC_RANDOM /*!<Player used key combination to change current music. */ + } MUSICTYPE; + +/*! + Class that handles sounds and music. +*/ +class SoundPlayerClass +{ +public: + //! @name Constructor & Destructor + //@{ + SoundPlayerClass(/*SETTINGSTYPE* settings*/); + ~SoundPlayerClass(); + //@} + + /*! + change type of current music + @param musicType type of music to be played + */ + void changeMusic(MUSICTYPE musicType); + + /*! + sets current music to MUSIC_PEACE if there's no + other song being played + */ + void musicCheck(); + + /*! + plays a certain sound at certain coordinates. + the volume of sound depends on the difference between + location of the sound and location of the view window + (the thing you see units in) + @param soundID id of the sound to be played + @param location coordinates where the sound is to be played + */ + void playSoundAt(int soundID, COORDTYPE* location); + + /*! + turns music playing on or off + @param value when true the function turns music on + */ + void setMusic(bool value); + void toggleSound(); + + void playVoice(int id, int house); + void playSound(int soundID); + + inline int GetSfxVolume() { return sfxVolume; }; + void SetSfxVolume(int newVolume) { + if(newVolume >= 0 && newVolume <= MIX_MAX_VOLUME) { + sfxVolume = newVolume; + } + } + + inline int GetMusicVolume() { return Mix_VolumeMusic(-1); }; + void SetMusicVolume(int newVolume) { + if(newVolume >= 0 && newVolume <= MIX_MAX_VOLUME) { + musicVolume = newVolume; + Mix_VolumeMusic(newVolume); + } + } + +private: + /*! + the function plays a sound with a given volume + @param soundID id of a sound to be played + @param volume sound will be played with this volume + */ + void playSound(int soundID, int volume); + vector<string> getMusicFileNames(string dir); + + vector<string> AttackMusic; + vector<string> IntroMusic; + vector<string> LoseMusic; + vector<string> PeaceMusic; + vector<string> WinMusic; + + //! whether sound should be played + bool soundOn; + //! whether music should be played + bool musicOn; + + //! volume of unit responses played when a unit is selected + int responseVolume; + //! volume of sound effects + int sfxVolume; + //! music volume + int musicVolume; + //! id of currently played music + int thisMusicID; + //! volume of voice over sounds + int voiceVolume; + + MUSICTYPE currentMusicType; + int currentMusicNum; + + Mix_Music* music; +}; +#endif //SOUNDPLAYERCLASS_H_INCLUDED Property changes on: branches/dunks/include/SoundPlayerClass.h ___________________________________________________________________ Name: svn:eol-style + native Added: branches/dunks/src/SoundPlayerClass.cpp =================================================================== --- branches/dunks/src/SoundPlayerClass.cpp (rev 0) +++ branches/dunks/src/SoundPlayerClass.cpp 2008-04-20 22:08:19 UTC (rev 150) @@ -0,0 +1,334 @@ +#include <stdlib.h> +#include <math.h> + +#include "pakfile/Vocfile.h" +#include "SoundPlayerClass.h" +#include "SDL_mixer.h" +#include "DuneConstants.h" +#include "mmath.h" +#include "gui/Graphics.h" +#include "DataCache.h" + +#include <algorithm> + + +Mix_Chunk* curVoiceChunk = NULL; +int voiceChannel = 0; +bool PlayingVoiceATM = false; + +void VoiceChunkFinishedCallback(int channel) { + if(channel == voiceChannel) { + PlayingVoiceATM = false; + } +} + +SoundPlayerClass::SoundPlayerClass() { + +/* AttackMusic = getMusicFileNames("./data/" + settings.Audio.MusicDirectory + "/attack/"); + IntroMusic = getMusicFileNames("./data/" + settings.Audio.MusicDirectory + "/intro/"); + LoseMusic = getMusicFileNames("./data/" + settings.Audio.MusicDirectory + "/lose/"); + PeaceMusic = getMusicFileNames("./data/" + settings.Audio.MusicDirectory + "/peace/"); + WinMusic = getMusicFileNames("./data/" + settings.Audio.MusicDirectory + "/win/"); +*/ + sfxVolume = MIX_MAX_VOLUME/2; + + musicVolume = MIX_MAX_VOLUME/2; + responseVolume = 100; + voiceVolume = 128; + + Mix_Volume(-1, MIX_MAX_VOLUME); + Mix_VolumeMusic(musicVolume); + + music = NULL; + thisMusicID = NONE; + currentMusicType = MUSIC_RANDOM; + currentMusicNum = 0; + + // init global variables + curVoiceChunk = NULL; + PlayingVoiceATM = false; + + voiceChannel = Mix_ReserveChannels(1); //Reserve a channel for voice over + Mix_ChannelFinished(VoiceChunkFinishedCallback); + + soundOn = true; + //soundOn = false; +// musicOn = true; + musicOn = false; +// changeMusic(MUSIC_INTRO); +} +SoundPlayerClass::~SoundPlayerClass() { + if(music != NULL) { + Mix_FreeMusic(music); + music = NULL; + } +} + +#if 0 +void SoundPlayerClass::changeMusic(MUSICTYPE musicType) +{ + int musicNum = -1; + string filename = ""; + + if(currentMusicType == musicType) { + return; + } + + switch(musicType) + { + case MUSIC_ATTACK: + if (currentMusicType != MUSIC_ATTACK) + { + if(AttackMusic.size() > 0) { + musicNum = getRandomInt(0, AttackMusic.size()-1); + filename = AttackMusic[musicNum]; + } + } + break; + case MUSIC_INTRO: + if (currentMusicType != MUSIC_INTRO) + { + if(IntroMusic.size() > 0) { + musicNum = getRandomInt(0, IntroMusic.size()-1); + filename = IntroMusic[musicNum]; + } + } + break; + case MUSIC_LOSE: + if (currentMusicType != MUSIC_LOSE) + { + if(LoseMusic.size() > 0) { + musicNum = getRandomInt(0, LoseMusic.size()-1); + filename = LoseMusic[musicNum]; + } + } + break; + case MUSIC_PEACE: + if (currentMusicType != MUSIC_PEACE) + { + if(PeaceMusic.size() > 0) { + musicNum = getRandomInt(0, PeaceMusic.size()-1); + filename = PeaceMusic[musicNum]; + } + } + break; + case MUSIC_WIN: + if (currentMusicType != MUSIC_WIN) + { + if(WinMusic.size() > 0) { + musicNum = getRandomInt(0, WinMusic.size()-1); + filename = WinMusic[musicNum]; + } + } + break; + case MUSIC_RANDOM: + default: + int maxnum = AttackMusic.size() + IntroMusic.size() + LoseMusic.size() + PeaceMusic.size() + WinMusic.size(); + + if(maxnum > 0) { + unsigned int randnum = getRandomInt(0, maxnum-1); + + if(randnum < AttackMusic.size()) { + musicNum = randnum; + filename = AttackMusic[musicNum]; + } else if(randnum < IntroMusic.size()) { + musicNum = randnum - AttackMusic.size(); + filename = IntroMusic[musicNum]; + } else if(randnum < LoseMusic.size()) { + musicNum = randnum - AttackMusic.size() - IntroMusic.size(); + filename = LoseMusic[musicNum]; + } else if(randnum < PeaceMusic.size()) { + musicNum = randnum - AttackMusic.size() - IntroMusic.size() - LoseMusic.size(); + filename = PeaceMusic[musicNum]; + } else { + musicNum = randnum - AttackMusic.size() - IntroMusic.size() - LoseMusic.size() - PeaceMusic.size(); + filename = WinMusic[musicNum]; + } + } + break; + } + currentMusicType = musicType; + + if((musicOn == true) && (filename != "")) { + + Mix_HaltMusic(); + + if(music != NULL) { + Mix_FreeMusic(music); + music = NULL; + } + + music = Mix_LoadMUS(filename.c_str()); + if(music != NULL) { + printf("Now playing %s!\n",filename.c_str()); + Mix_PlayMusic(music, -1); + } else { + printf("Unable to play %s!\n",filename.c_str()); + } + + /* + Mix_Chunk *sample; + sample=Mix_LoadWAV(filename.c_str()); + Mix_PlayChannel(-1, sample, 0);*/ + } +} +/*void SoundPlayerClass::musicCheck() +{ + if (musicOn) + { + if ( ! Mix_PlayingMusic() ) + changeMusic(MUSIC_PEACE); + } +}*/ +#endif +#if 0 +void SoundPlayerClass::playSoundAt(int soundID, COORDTYPE* location) +{ + if (soundOn) + { + int volume = sfxVolume, + panning = 128, + xOffset = 0, + yOffset = 0; + + if (location->x > dborder->maxX/BLOCKSIZE) + { + xOffset = location->x - dborder->maxX/BLOCKSIZE; + panning += xOffset; + } + else if (location->x < dborder->minX/BLOCKSIZE) + { + xOffset = dborder->minX/BLOCKSIZE - location->x; + panning -= xOffset; + } + + if (location->y > dborder->maxY/BLOCKSIZE) + yOffset = location->y - dborder->maxY/BLOCKSIZE; + else if (location->y < dborder->minY/BLOCKSIZE) + yOffset = dborder->minY/BLOCKSIZE - location->y; + + volume -= (int)(10*(sqrt((double)(xOffset*xOffset + yOffset*yOffset)))); + if (volume < 15) volume = 15; + + playSound(soundID, volume); + } +} +#endif +#if 0 +void SoundPlayerClass::setMusic(bool value) +{ + musicOn = value; + + if (musicOn) + changeMusic(MUSIC_RANDOM); + else if (music != NULL) + Mix_HaltMusic(); +} +#endif + +void SoundPlayerClass::toggleSound() +{ + if (!soundOn && !musicOn) + { + soundOn = true; +// currentGame->AddToNewsTicker("sound on, music off"); + } + else if (soundOn && !musicOn) + { + musicOn = true; + soundOn = false; +// currentGame->AddToNewsTicker("sound off, music on"); + currentMusicType = MUSIC_RANDOM; +// changeMusic(MUSIC_PEACE); + } + else if (!soundOn && musicOn) + { + soundOn = true; +// currentGame->AddToNewsTicker("sound on, music on"); + } + else if (soundOn && musicOn) + { + soundOn = false; + musicOn = false; +// currentGame->AddToNewsTicker("sound off, music off"); + + if (music != NULL) + Mix_HaltMusic(); + } +} + +void SoundPlayerClass::playSound(int soundID, int volume) +{ + if (soundOn) + { + Mix_Chunk* tmp; + + if((tmp = DataCache::Instance()->getSoundChunk(soundID)) == NULL) { + return; + } + + int channel = Mix_PlayChannel(-1,tmp, 0); + if (channel != -1) + Mix_Volume(channel, (volume*sfxVolume)/MIX_MAX_VOLUME); + } +} + +#if 0 +void SoundPlayerClass::playVoice(int id, int house) { + if (soundOn) + { + Mix_Chunk* tmp; + + if((tmp = pDataManager->GetVoice(id,house)) == NULL) { + fprintf(stderr,"There is no voice with id %d!\n",id); + exit(EXIT_FAILURE); + } + + int channel = Mix_PlayChannel(-1, tmp, 0); + Mix_Volume(channel,sfxVolume); + } +} +#endif + +void SoundPlayerClass::playSound(int soundID) { + if (soundOn) + { + Mix_Chunk* tmp; + + if((tmp = DataCache::Instance()->getSoundChunk(soundID)) == NULL) { + fprintf(stderr,"There is no sound with id %d!\n",soundID); + exit(EXIT_FAILURE); + } + + Mix_PlayChannel(-1, tmp, 0); + } +} +#if 0 +vector<string> SoundPlayerClass::getMusicFileNames(string dir) { + vector<string> Files; + std::list<std::string> tmp; + std::list<std::string>::const_iterator iter; + + tmp = GetFileNames(dir,"mp3",true); + for(iter = tmp.begin(); iter != tmp.end(); iter++) { + Files.push_back(dir + *iter); + } + + tmp = GetFileNames(dir,"ogg",true); + for(iter = tmp.begin(); iter != tmp.end(); iter++) { + Files.push_back(dir + *iter); + } + + tmp = GetFileNames(dir,"wav",true); + for(iter = tmp.begin(); iter != tmp.end(); iter++) { + Files.push_back(dir + *iter); + } + + tmp = GetFileNames(dir,"mid",true); + for(iter = tmp.begin(); iter != tmp.end(); iter++) { + Files.push_back(dir + *iter); + } + + return Files; +} +#endif Property changes on: branches/dunks/src/SoundPlayerClass.cpp ___________________________________________________________________ Name: svn:eol-style + native This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dv...@us...> - 2008-04-20 22:04:03
|
Revision: 149 http://dunelegacy.svn.sourceforge.net/dunelegacy/?rev=149&view=rev Author: dvalin Date: 2008-04-20 15:04:00 -0700 (Sun, 20 Apr 2008) Log Message: ----------- start on merging sound stuff from richie's branch Modified Paths: -------------- branches/dunks/include/DataCache.h branches/dunks/include/ResMan.h branches/dunks/src/Application.cpp branches/dunks/src/DataCache.cpp branches/dunks/src/SConscript Modified: branches/dunks/include/DataCache.h =================================================================== --- branches/dunks/include/DataCache.h 2008-04-20 22:03:12 UTC (rev 148) +++ branches/dunks/include/DataCache.h 2008-04-20 22:04:00 UTC (rev 149) @@ -6,6 +6,7 @@ #include "Settings.h" #include "ResMan.h" #include "singleton.h" +#include "SDL_mixer.h" #include "pakfile/Cpsfile.h" #include "pakfile/Icnfile.h" @@ -290,7 +291,7 @@ HouseHarkonnen, PlaceStructure, ButtonClick, - InvalidAction, +// InvalidAction, CreditsTick, RadarNoise, Sound_ExplosionGas, @@ -309,8 +310,64 @@ Sound_Scream4, Sound_Scream5, Sound_MachineGun, - Sound_Sonic, +// Sound_Sonic, Sound_RocketSmall, + Intro_3Houses, + Intro_AndNow, + Intro_Battle, + Intro_Begins, + Intro_Blaster, + Intro_TheBuilding, + Intro_Blowup_1, + Intro_Blowup_2, + Intro_Brakes_2p, + Intro_Clank, + Intro_Click, + Intro_ControlsDune, + Intro_ControlsTheSpice, + Intro_ForControl, + Intro_Controls, + Intro_Dune, + Intro_OfADynasty, + Intro_ToEachOfTheHouses, + Intro_AndNo, + Intro_WillControlDune, + Intro_TheHouse, + Intro_TheMostSpice, + Intro_TheEmpire, + Intro_ThereAreNoSetTerritories, + Intro_ThatProduces, + Intro_RulesOfEngagement, + Intro_Territories, + Intro_AndThe, +// Intro_Filler, + Intro_Flesh, + Intro_Glass_6, + Intro_Glass, + Intro_GunShot, + Intro_EvilHarkonnen, + Intro_Home, + Intro_OnlyOneHouse, + Intro_TheInsideous, + Intro_TheEmperor, + Intro_KnownAsDune, + Intro_Worm, + Intro_Melange, + Intro_Missile_8, + Intro_TheNobleAtreides, + Intro_Now, + Intro_OfDune, + Intro_Ordos, + Intro_ThePlanetArrakis, + Intro_WillPrevail, + Intro_HasProposedAChallenge, + Intro_LandOfSand, + Intro_OfTheSpice, + Intro_TheSpice, + Intro_VastArmies, + Intro_WhoEver, + Intro_Wind_2bp, + Intro_Your, NUM_SOUNDCHUNK } Sound_enum; @@ -327,13 +384,22 @@ public: void addObjPic(unsigned ID, SDL_Surface * tmp); - void addVoice(unsigned ID, std::string vocFile); + void addSoundChunk(unsigned ID, Mix_Chunk* tmp); ImagePtr getObjPic(unsigned ID, unsigned house = HOUSE_HARKONNEN); + Mix_Chunk* getSoundChunk(unsigned ID); private: bool addObjPic(unsigned ID) { return false;}; remapped_images m_objImg; remapped_images m_guiImg; + + Mix_Chunk* getChunkFromFile(std::string fileName); + Mix_Chunk* concat2Chunks(Mix_Chunk* sound1, Mix_Chunk* sound2); + Mix_Chunk* concat3Chunks(Mix_Chunk* sound1, Mix_Chunk* sound2, Mix_Chunk* sound3); + Mix_Chunk* createEmptyChunk(); + + Mix_Chunk* soundChunk[NUM_SOUNDCHUNK]; + }; #endif // DUNE_DATACACHE_H Modified: branches/dunks/include/ResMan.h =================================================================== --- branches/dunks/include/ResMan.h 2008-04-20 22:03:12 UTC (rev 148) +++ branches/dunks/include/ResMan.h 2008-04-20 22:04:00 UTC (rev 149) @@ -1,27 +1,27 @@ -#ifndef DUNE_RESMAN_H -#define DUNE_RESMAN_H - -#include "singleton.h" -#include "pakfile/Pakfile.h" - -#include "boost/filesystem/path.hpp" - -#include <map> -#include <string> - -//#include "Log.h" - -/*! - Class to emulate a file object using an unsigned char* buffer -*/ -class FileLike -{ - public: +#ifndef DUNE_RESMAN_H +#define DUNE_RESMAN_H + +#include "singleton.h" +#include "pakfile/Pakfile.h" + +#include "boost/filesystem/path.hpp" + +#include <map> +#include <string> + +//#include "Log.h" + +/*! + Class to emulate a file object using an unsigned char* buffer +*/ +class FileLike +{ + public: //! @name Constructors & Destructor - //@{ - FileLike(unsigned char* buf, int size); - ~FileLike(); - //@} + //@{ + FileLike(unsigned char* buf, int size); + ~FileLike(); + //@} //! @name FileLike methods //@{ @@ -29,182 +29,182 @@ read data from the buffer @param buf buffer to read data into @param size amount of bytes to read - */ - void read(void* buf, int size); - /*! - seek to a position in the buffer - @param offset offset from the beginning of the buffer in bytes - */ - void seek(int offset); - //@} - - private: - unsigned char* m_buf; - int m_size; - int m_pos; -}; - -/*! - Base class for all resources. -*/ -class Resource -{ - public: + */ + void read(void* buf, int size); + /*! + seek to a position in the buffer + @param offset offset from the beginning of the buffer in bytes + */ + void seek(int offset); + //@} + + private: + unsigned char* m_buf; + int m_size; + int m_pos; +}; + +/*! + Base class for all resources. +*/ +class Resource +{ + public: //! @name Constructors & Destructor - //@{ - Resource(); - virtual ~Resource(); - //@} - - /*! - read a file from the resource. - @param path path to the file to read - @param size if not NULL the file size is put here - @return file data - */ - virtual unsigned char* readFile(std::string path, int *size) { return NULL; } - - /*! - read a text file from resource - @param path path to the file to open - @return text from the file - */ - virtual std::string readText(std::string path) { return ""; } - /*! - write a text file to a resource - @param path path to write the file - @param text text to write to file - */ - virtual void writeText(std::string path, std::string text) {} - - /*! - return true if the resource can be written to - */ - inline bool isWritable() { return mb_writable; } - - /*! - return true if the file exists - */ - virtual bool exists(std::string path) { return false; } - - protected: - boost::filesystem::path m_path; + //@{ + Resource(); + virtual ~Resource(); + //@} - bool mb_writable; + /*! + read a file from the resource. + @param path path to the file to read + @param size if not NULL the file size is put here + @return file data + */ + virtual unsigned char* readFile(std::string path, int *size) { return NULL; } + + /*! + read a text file from resource + @param path path to the file to open + @return text from the file + */ + virtual std::string readText(std::string path) { return ""; } + /*! + write a text file to a resource + @param path path to write the file + @param text text to write to file + */ + virtual void writeText(std::string path, std::string text) {} -}; - -/*! - Directory Resource - all files are read from a directory -*/ -class DIRResource : public Resource -{ - public: - DIRResource(boost::filesystem::path path) ; - unsigned char* readFile(std::string path, int *size); - std::string readText(std::string path); - bool exists(std::string path); -}; - -/*! - Writable directory resource for storing config files -*/ -class WritableDIRResource : public DIRResource -{ - public: - WritableDIRResource(std::string path); - void writeText(std::string path, std::string text); -}; - -/*! - PAK file resource - all files are read from a PAK file -*/ -class PAKResource : public Resource -{ - public: - PAKResource(boost::filesystem::path path) ; - ~PAKResource(); - unsigned char* readFile(std::string path, int *size); - bool exists(std::string path); - private: - Pakfile *m_pakfile; -}; - -/*! - Class to simplify reading and writing from different resource files. -*/ -class ResMan : public Singleton<ResMan> -{ - friend class Singleton<ResMan>; - - typedef std::map<std::string, Resource*> ResList; - - protected: - ResMan(); - ~ResMan(); - - public: - //! @name resource management - //@{ - /*! - add a resource to the manager. the resource will be searched for - in the directory pointed to by Settings::GetDataDir. It will - first search for a directory and then for the pak file - @ param name name of the resource to open - @ return true on success - */ - bool addRes(std::string name); - /*! - add an existing resource to the resource manager. - */ - bool addRes(std::string name, Resource *res); - - Resource* getResource(std::string name, std::string& filename); - //@} - + /*! + return true if the resource can be written to + */ + inline bool isWritable() { return mb_writable; } + + /*! + return true if the file exists + */ + virtual bool exists(std::string path) { return false; } + + protected: + boost::filesystem::path m_path; + + bool mb_writable; + +}; + +/*! + Directory Resource - all files are read from a directory +*/ +class DIRResource : public Resource +{ + public: + DIRResource(boost::filesystem::path path) ; + unsigned char* readFile(std::string path, int *size); + std::string readText(std::string path); + bool exists(std::string path); +}; + +/*! + Writable directory resource for storing config files +*/ +class WritableDIRResource : public DIRResource +{ + public: + WritableDIRResource(std::string path); + void writeText(std::string path, std::string text); +}; + +/*! + PAK file resource - all files are read from a PAK file +*/ +class PAKResource : public Resource +{ + public: + PAKResource(boost::filesystem::path path) ; + ~PAKResource(); + unsigned char* readFile(std::string path, int *size); + bool exists(std::string path); + private: + Pakfile *m_pakfile; +}; + +/*! + Class to simplify reading and writing from different resource files. +*/ +class ResMan : public Singleton<ResMan> +{ + friend class Singleton<ResMan>; + + typedef std::map<std::string, Resource*> ResList; + + protected: + ResMan(); + ~ResMan(); + + public: + //! @name resource management + //@{ + /*! + add a resource to the manager. the resource will be searched for + in the directory pointed to by Settings::GetDataDir. It will + first search for a directory and then for the pak file + @ param name name of the resource to open + @ return true on success + */ + bool addRes(std::string name); + /*! + add an existing resource to the resource manager. + */ + bool addRes(std::string name, Resource *res); + + Resource* getResource(std::string name, std::string& filename); + //@} + //! @name binary functions - //@{ - /*! - read a file from the resource. - @param path path to the file to read - @param size if not NULL the file size is put here - @return file data - */ - unsigned char* readFile(std::string path, int *size); - /*! - read a file from the resource. - @param path path to the file to read - @return FileLike object - */ - FileLike* readFile(std::string path); - //@} - + //@{ + /*! + read a file from the resource. + @param path path to the file to read + @param size if not NULL the file size is put here + @return file data + */ + unsigned char* readFile(std::string path, int *size); + /*! + read a file from the resource. + @param path path to the file to read + @return FileLike object + */ + FileLike* readFile(std::string path); + //@} + //! @name textmode functions - //@{ - /*! - read a text file from resource - @param path path to the file to open - @return text from the file - */ - virtual std::string readText(std::string path); - /*! - write a text file to a resource - @param path path to write the file - @param text text to write to file - */ - virtual void writeText(std::string path, std::string text); - //@} - - /*! - return true if the path exists - */ - bool exists(std::string path); - - private: - ResList m_resources; -}; - -#endif // DUNE_RESMAN_H - - - + //@{ + /*! + read a text file from resource + @param path path to the file to open + @return text from the file + */ + virtual std::string readText(std::string path); + /*! + write a text file to a resource + @param path path to write the file + @param text text to write to file + */ + virtual void writeText(std::string path, std::string text); + //@} + + /*! + return true if the path exists + */ + bool exists(std::string path); + + private: + ResList m_resources; +}; + +#endif // DUNE_RESMAN_H + + + Modified: branches/dunks/src/Application.cpp =================================================================== --- branches/dunks/src/Application.cpp 2008-04-20 22:03:12 UTC (rev 148) +++ branches/dunks/src/Application.cpp 2008-04-20 22:04:00 UTC (rev 149) @@ -3,7 +3,7 @@ #include "SDL.h" //#include "SDL_ttf.h" //#include "SDL_net.h" -//#include "SDL_mixer.h" +#include "SDL_mixer.h" #include <stdio.h> #include <stdlib.h> @@ -17,12 +17,12 @@ //#include "Net.h" //#include "data.h" //#include "ui.h" -//#include "SoundPlayerClass.h" +#include "SoundPlayerClass.h" #include "Colours.h" #include "Settings.h" #include "Font.h" #include "TopLevelState.h" -//#include "DataFile.h" +#include "DataCache.h" #include "Gfx.h" #include "pakfile/Palette.h" #include "pakfile/Shpfile.h" @@ -65,7 +65,7 @@ void Application::Init() { - /* + int lookDist[11]; lookDist[0] = 10; lookDist[1] = 10; lookDist[2] = 9; @@ -82,7 +82,6 @@ InitSettings(); srand(time(NULL)); - */ Uint32 flags = SDL_INIT_AUDIO | \ SDL_INIT_TIMER | \ @@ -100,7 +99,7 @@ // replace NULL with a path to a 32x32 icon SDL_WM_SetCaption("Dune Legacy", NULL); - //InitAudio(); + InitAudio(); //InitNet(); // force font manager to be loaded @@ -147,7 +146,6 @@ void Application::InitSettings() { - /* settings.concreteRequired = true; settings.gameType = ORIGINAL; settings.playerType = SINGLE; @@ -159,12 +157,11 @@ settings.playerHouse[settings.playerNum] = settings.playerNum; strcpy(settings.localPlayerName, "Player"); - */ } void Application::InitAudio() { - /* + printf("initialising sound.....\n"); if ( Mix_OpenAudio(11025, MIX_DEFAULT_FORMAT, 2, 512) < 0 ) @@ -177,7 +174,6 @@ { printf("allocated %d channels.\n", Mix_AllocateChannels(16)); }; - */ } void Application::InitNet() @@ -277,6 +273,7 @@ ResMan::Instance()->addRes("ATRE"); ResMan::Instance()->addRes("DUNE"); ResMan::Instance()->addRes("ENGLISH"); + ResMan::Instance()->addRes("GERMAN"); ResMan::Instance()->addRes("FINALE"); ResMan::Instance()->addRes("HARK"); ResMan::Instance()->addRes("HERC"); @@ -303,17 +300,16 @@ m_cursor.reset(new Image(mouse.getPicture(0))); - /* + fprintf(stdout, "starting sound...\n"); - soundPlayer = new SoundPlayerClass(); - */ + SoundPlayerClass* soundPlayer = new SoundPlayerClass(); } void Application::Die() { FontManager::Destroy(); //TTF_Quit(); - //Mix_CloseAudio(); + Mix_CloseAudio(); //SDLNet_Quit(); SDL_Quit(); exit(1); Modified: branches/dunks/src/DataCache.cpp =================================================================== --- branches/dunks/src/DataCache.cpp 2008-04-20 22:03:12 UTC (rev 148) +++ branches/dunks/src/DataCache.cpp 2008-04-20 22:04:00 UTC (rev 149) @@ -1,8 +1,6 @@ #include "DataCache.h" +#include "pakfile/Vocfile.h" - -using namespace std; - DataCache::DataCache() { for (int i=0; i< NUM_HOUSES; i++) { @@ -95,11 +93,105 @@ addObjPic(ObjPic_RockDamage, icon->getPictureRow(1,6)); addObjPic(ObjPic_SandDamage, units1->getPictureArray(3,1,5|TILE_NORMAL,6|TILE_NORMAL,7|TILE_NORMAL)); addObjPic(ObjPic_Terrain_Hidden, icon->getPictureRow(108,123)); -} + addSoundChunk(YesSir, getChunkFromFile("VOC:ZREPORT1.VOC")); + addSoundChunk(Reporting, getChunkFromFile("VOC:ZREPORT2.VOC")); + addSoundChunk(Acknowledged, getChunkFromFile("VOC:ZREPORT3.VOC")); + addSoundChunk(Affirmative, getChunkFromFile("VOC:ZAFFIRM.VOC")); + addSoundChunk(MovingOut, getChunkFromFile("VOC:ZMOVEOUT.VOC")); + addSoundChunk(InfantryOut, getChunkFromFile("VOC:ZOVEROUT.VOC")); + addSoundChunk(SomethingUnderTheSand, getChunkFromFile("VOC:SANDBUG.VOC")); + addSoundChunk(HouseAtreides, getChunkFromFile("GERMAN:GATRE.VOC")); + addSoundChunk(HouseOrdos, getChunkFromFile("GERMAN:GORDOS.VOC")); + addSoundChunk(HouseHarkonnen, getChunkFromFile("GERMAN:GHARK.VOC")); + + addSoundChunk(PlaceStructure, getChunkFromFile("VOC:EXDUD.VOC")); + addSoundChunk(ButtonClick, getChunkFromFile("VOC:BUTTON.VOC")); +// addSoundChunk(InvalidAction, Mix_LoadWAV_RW(pFileManager->OpenFile("CANNOT.WAV"),1)); + // probably incorrect? + addSoundChunk(CreditsTick, getChunkFromFile("INTROVOC:CLICK.VOC")); + addSoundChunk(RadarNoise, getChunkFromFile("VOC:STATICP.VOC")); + addSoundChunk(Sound_ExplosionGas, getChunkFromFile("VOC:EXGAS.VOC")); + addSoundChunk(Sound_ExplosionTiny, getChunkFromFile("VOC:EXTINY.VOC")); + addSoundChunk(Sound_ExplosionSmall, getChunkFromFile("VOC:EXSMALL.VOC")); + addSoundChunk(Sound_ExplosionMedium, getChunkFromFile("VOC:EXMED.VOC")); + addSoundChunk(Sound_ExplosionLarge, getChunkFromFile("VOC:EXLARGE.VOC")); + addSoundChunk(Sound_ExplosionStructure, getChunkFromFile("VOC:CRUMBLE.VOC")); + addSoundChunk(Sound_WormAttack, getChunkFromFile("VOC:WORMET3P.VOC")); + addSoundChunk(Sound_Gun, getChunkFromFile("VOC:GUN.VOC")); + addSoundChunk(Sound_Rocket, getChunkFromFile("VOC:ROCKET.VOC")); + addSoundChunk(Sound_Bloom, getChunkFromFile("VOC:EXSAND.VOC")); + addSoundChunk(Sound_Scream1, getChunkFromFile("VOC:VSCREAM1.VOC")); + addSoundChunk(Sound_Scream2, getChunkFromFile("VOC:VSCREAM1.VOC")); + addSoundChunk(Sound_Scream3, getChunkFromFile("VOC:VSCREAM1.VOC")); + addSoundChunk(Sound_Scream4, getChunkFromFile("VOC:VSCREAM1.VOC")); + addSoundChunk(Sound_Scream5, getChunkFromFile("VOC:VSCREAM1.VOC")); + addSoundChunk(Sound_MachineGun, getChunkFromFile("VOC:GUNMULTI.VOC")); +// addSoundChunk(Sound_Sonic, Mix_LoadWAV_RW(pFileManager->OpenFile("SONIC.WAV"),1); + addSoundChunk(Sound_RocketSmall, getChunkFromFile("VOC:MISLTINP.VOC")); + + addSoundChunk(Intro_3Houses, getChunkFromFile("INTROVOC:3HOUSES.VOC")); + addSoundChunk(Intro_AndNow, getChunkFromFile("INTROVOC:ANDNOW.VOC")); + addSoundChunk(Intro_Battle, getChunkFromFile("INTROVOC:ARRIVED.VOC")); + addSoundChunk(Intro_Begins, getChunkFromFile("INTROVOC:BEGINS.VOC")); + addSoundChunk(Intro_Blaster, getChunkFromFile("INTROVOC:BLASTER.VOC")); + addSoundChunk(Intro_TheBuilding, getChunkFromFile("INTROVOC:BLDING.VOC")); + addSoundChunk(Intro_Blowup_1, getChunkFromFile("INTROVOC:BLOWUP1.VOC")); + addSoundChunk(Intro_Blowup_2, getChunkFromFile("INTROVOC:BLOWUP2.VOC")); + addSoundChunk(Intro_Brakes_2p, getChunkFromFile("INTROVOC:BRAKES2P.VOC")); + addSoundChunk(Intro_Clank, getChunkFromFile("INTROVOC:CLANK.VOC")); + addSoundChunk(Intro_Click, getChunkFromFile("INTROVOC:CLICK.VOC")); + addSoundChunk(Intro_ControlsDune, getChunkFromFile("INTROVOC:CONTROL2.VOC")); + addSoundChunk(Intro_ControlsTheSpice, getChunkFromFile("INTROVOC:CONTROL3.VOC")); + addSoundChunk(Intro_ForControl, getChunkFromFile("INTROVOC:CONTROL4.VOC")); + addSoundChunk(Intro_Controls, getChunkFromFile("INTROVOC:CONTROLS.VOC")); + addSoundChunk(Intro_Dune, getChunkFromFile("INTROVOC:DUNE.VOC")); + addSoundChunk(Intro_OfADynasty, getChunkFromFile("INTROVOC:DYNASTY.VOC")); + addSoundChunk(Intro_ToEachOfTheHouses, getChunkFromFile("INTROVOC:EACHHOME.VOC")); + addSoundChunk(Intro_AndNo, getChunkFromFile("INTROVOC:EANDNO.VOC")); + addSoundChunk(Intro_WillControlDune, getChunkFromFile("INTROVOC:ECONTROL.VOC")); + addSoundChunk(Intro_TheHouse, getChunkFromFile("INTROVOC:EHOUSE.VOC")); + addSoundChunk(Intro_TheMostSpice, getChunkFromFile("INTROVOC:EMOST.VOC")); + addSoundChunk(Intro_TheEmpire, getChunkFromFile("INTROVOC:EMPIRE.VOC")); + addSoundChunk(Intro_ThereAreNoSetTerritories, getChunkFromFile("INTROVOC:ENOSET.VOC")); + addSoundChunk(Intro_ThatProduces, getChunkFromFile("INTROVOC:EPRODUCE.VOC")); + addSoundChunk(Intro_RulesOfEngagement, getChunkFromFile("INTROVOC:ERULES.VOC")); + addSoundChunk(Intro_Territories, getChunkFromFile("INTROVOC:ETERRIT.VOC")); + addSoundChunk(Intro_AndThe, getChunkFromFile("INTROVOC:EVIL.VOC")); +// addSoundChunk(Intro_Filler, getChunkFromFile("INTROVOC:FILLER.VOC")); + addSoundChunk(Intro_Flesh, getChunkFromFile("INTROVOC:FLESH.VOC")); + addSoundChunk(Intro_Glass_6, getChunkFromFile("INTROVOC:GLASS6.VOC")); + addSoundChunk(Intro_Glass, getChunkFromFile("INTROVOC:GLASS.VOC")); + addSoundChunk(Intro_GunShot, getChunkFromFile("INTROVOC:GUNSHOT.VOC")); + addSoundChunk(Intro_EvilHarkonnen, getChunkFromFile("INTROVOC:HARK.VOC")); + addSoundChunk(Intro_Home, getChunkFromFile("INTROVOC:HOME.VOC")); + addSoundChunk(Intro_OnlyOneHouse, getChunkFromFile("INTROVOC:HOUSE2.VOC")); + addSoundChunk(Intro_TheInsideous, getChunkFromFile("INTROVOC:INSID.VOC")); + addSoundChunk(Intro_TheEmperor, getChunkFromFile("INTROVOC:KING.VOC")); + addSoundChunk(Intro_KnownAsDune, getChunkFromFile("INTROVOC:KNOWN.VOC")); + addSoundChunk(Intro_Worm, getChunkFromFile("INTROVOC:LIZARD1.VOC")); + addSoundChunk(Intro_Melange, getChunkFromFile("INTROVOC:MELANGE.VOC")); + addSoundChunk(Intro_Missile_8, getChunkFromFile("INTROVOC:MISSLE8.VOC")); + addSoundChunk(Intro_TheNobleAtreides, getChunkFromFile("INTROVOC:NOBLE.VOC")); + addSoundChunk(Intro_Now, getChunkFromFile("INTROVOC:NOW.VOC")); + addSoundChunk(Intro_OfDune, getChunkFromFile("INTROVOC:OFDUNE.VOC")); + addSoundChunk(Intro_Ordos, getChunkFromFile("INTROVOC:ORD.VOC")); + addSoundChunk(Intro_ThePlanetArrakis, getChunkFromFile("INTROVOC:PLANET.VOC")); + addSoundChunk(Intro_WillPrevail, getChunkFromFile("INTROVOC:PREVAIL.VOC")); + addSoundChunk(Intro_HasProposedAChallenge, getChunkFromFile("INTROVOC:PROPOSED.VOC")); + addSoundChunk(Intro_LandOfSand, getChunkFromFile("INTROVOC:SANDLAND.VOC")); + addSoundChunk(Intro_OfTheSpice, getChunkFromFile("INTROVOC:SPICE.VOC")); + addSoundChunk(Intro_TheSpice, getChunkFromFile("INTROVOC:SPICE2.VOC")); + addSoundChunk(Intro_VastArmies, getChunkFromFile("INTROVOC:VAST.VOC")); + addSoundChunk(Intro_WhoEver, getChunkFromFile("INTROVOC:WHOEVER.VOC")); + addSoundChunk(Intro_Wind_2bp, getChunkFromFile("INTROVOC:WIND2BP.VOC")); + addSoundChunk(Intro_Your, getChunkFromFile("INTROVOC:YOUR.VOC")); + +}; + void DataCache::addObjPic(unsigned ID, SDL_Surface * tmp) { - m_objImg[HOUSE_HARKONNEN]->insert(pair<unsigned, ImagePtr>(ID, + m_objImg[HOUSE_HARKONNEN]->insert(std::pair<unsigned, ImagePtr>(ID, ImagePtr(new Image(tmp)))); } @@ -114,15 +206,39 @@ { ImagePtr source = m_objImg[HOUSE_HARKONNEN]->find(ID)->second; ImagePtr copy = source->getRecoloredByHouse(house); - m_objImg[HOUSE_HARKONNEN]->insert(pair<unsigned, ImagePtr>(ID, copy)); + m_objImg[HOUSE_HARKONNEN]->insert(std::pair<unsigned, ImagePtr>(ID, copy)); return copy; } } -/*void DataCache::addVoice(unsigned ID, std::string){ +void DataCache::addSoundChunk(unsigned ID, Mix_Chunk* tmp){ + soundChunk[ID] = tmp; +} + +Mix_Chunk* DataCache::getSoundChunk(unsigned ID){ + return soundChunk[ID]; +} +Mix_Chunk* DataCache::getChunkFromFile(std::string fileName) { + Mix_Chunk* returnChunk; + SDL_RWops* rwop; + unsigned char * data; + + int len; + data = ResMan::Instance()->readFile(fileName.c_str(), &len); + if((rwop = SDL_RWFromMem(data, len)) ==NULL) { + fprintf(stderr,"DataManager::getChunkFromFile(): Cannot open %s!\n",fileName.c_str()); + exit(EXIT_FAILURE); + } -}*/ + if((returnChunk = LoadVOC_RW(rwop, 0)) == NULL) { + fprintf(stderr,"DataManager::getChunkFromFile(): Cannot load %s!\n",fileName.c_str()); + exit(EXIT_FAILURE); + } + + SDL_RWclose(rwop); + return returnChunk; +} DataCache::~DataCache() { Modified: branches/dunks/src/SConscript =================================================================== --- branches/dunks/src/SConscript 2008-04-20 22:03:12 UTC (rev 148) +++ branches/dunks/src/SConscript 2008-04-20 22:04:00 UTC (rev 149) @@ -17,7 +17,7 @@ "Settings.cpp", "Font.cpp", "State.cpp", -# "DataFile.cpp", + "DataCache.cpp", # "PictureFactory.cpp", "TopLevelState.cpp", "MenuBase.cpp", @@ -32,6 +32,12 @@ "ConfigFile.cpp", "ResMan.cpp", + "SoundPlayerClass.cpp", + "pakfile/Vocfile.cpp", + "pakfile/IntegratedLibSampleRate/samplerate.c", + "pakfile/IntegratedLibSampleRate/src_linear.c", + "pakfile/IntegratedLibSampleRate/src_sinc.c", + "pakfile/IntegratedLibSampleRate/src_zoh.c" ] gui_sources = [ @@ -64,6 +70,12 @@ "Strings.cpp", "State.cpp", "TopLevelState.cpp", + "SoundPlayerClass.cpp", + "pakfile/Vocfile.cpp", + "pakfile/IntegratedLibSampleRate/samplerate.c", + "pakfile/IntegratedLibSampleRate/src_linear.c", + "pakfile/IntegratedLibSampleRate/src_sinc.c", + "pakfile/IntegratedLibSampleRate/src_zoh.c" ] #gamelib = env.StaticLibrary("dune_game", all_sources) @@ -74,5 +86,5 @@ pakview = env.Program("../test", ["pakview.cpp"] + pakview_sources + gui_sources + pak_sources ) Default(dunelegacy) -#Default(pakview) +Default(pakview) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dv...@us...> - 2008-04-20 22:03:20
|
Revision: 148 http://dunelegacy.svn.sourceforge.net/dunelegacy/?rev=148&view=rev Author: dvalin Date: 2008-04-20 15:03:12 -0700 (Sun, 20 Apr 2008) Log Message: ----------- rename to avoid backslash escape annoyance on *NIX Added Paths: ----------- branches/dunks/old_include/ branches/dunks/old_src/ Removed Paths: ------------- branches/dunks/old\include/ branches/dunks/old\src/ Copied: branches/dunks/old_include (from rev 138, branches/dunks/old\include) Copied: branches/dunks/old_src (from rev 138, branches/dunks/old\src) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dv...@us...> - 2008-04-20 19:08:17
|
Revision: 147 http://dunelegacy.svn.sourceforge.net/dunelegacy/?rev=147&view=rev Author: dvalin Date: 2008-04-20 12:08:05 -0700 (Sun, 20 Apr 2008) Log Message: ----------- add some media to list from richie's branch Modified Paths: -------------- branches/dunks/include/DataCache.h Modified: branches/dunks/include/DataCache.h =================================================================== --- branches/dunks/include/DataCache.h 2008-04-20 19:07:01 UTC (rev 146) +++ branches/dunks/include/DataCache.h 2008-04-20 19:08:05 UTC (rev 147) @@ -18,67 +18,71 @@ #include <map> #include <vector> +#define NUM_MAPCHOICEPIECES 28 +#define NUM_MAPCHOICEARROWS 9 + +// ObjPics typedef enum { - ObjImg_Tank_Base, - ObjImg_Tank_Gun, - ObjImg_Siegetank_Base, - ObjImg_Siegetank_Gun, - ObjImg_Devastator_Base, - ObjImg_Devastator_Gun, - ObjImg_Sonictank_Gun, - ObjImg_Launcher_Gun, - ObjImg_Quad, - ObjImg_Trike, - ObjImg_Harvester, - ObjImg_Harvester_Sand, - ObjImg_MCV, - ObjImg_Carryall, - ObjImg_Frigate, - ObjImg_Ornithopter, - ObjImg_Trooper, - ObjImg_Infantry, - ObjImg_Saboteur, - ObjImg_Sandworm, - ObjImg_ConstructionYard, - ObjImg_Windtrap, - ObjImg_Refinery, - ObjImg_Barracks, - ObjImg_WOR, - ObjImg_Radar, - ObjImg_LightFactory, - ObjImg_Silo, - ObjImg_HeavyFactory, - ObjImg_HighTechFactory, - ObjImg_IX, - ObjImg_Palace, - ObjImg_RepairYard, - ObjImg_Starport, - ObjImg_GunTurret, - ObjImg_RocketTurret, - ObjImg_Wall, - ObjImg_Bullet_SmallRocket, - ObjImg_Bullet_MediumRocket, - ObjImg_Bullet_LargeRocket, - ObjImg_Bullet_Small, - ObjImg_Bullet_Medium, - ObjImg_Bullet_Sonic, - ObjImg_Hit_Gas, - ObjImg_Hit_Shell, - ObjImg_ExplosionSmall, - ObjImg_ExplosionMedium1, - ObjImg_ExplosionMedium2, - ObjImg_ExplosionLarge1, - ObjImg_ExplosionLarge2, - ObjImg_ExplosionSmallUnit, - ObjImg_DeadInfantry, - ObjImg_Smoke, - ObjImg_SandwormShimmerMask, - ObjImg_Terrain, - ObjImg_RockDamage, - ObjImg_SandDamage, - ObjImg_Terrain_Hidden, - NUM_OBJIMGS -} ObjImg_enum; + ObjPic_Tank_Base, + ObjPic_Tank_Gun, + ObjPic_Siegetank_Base, + ObjPic_Siegetank_Gun, + ObjPic_Devastator_Base, + ObjPic_Devastator_Gun, + ObjPic_Sonictank_Gun, + ObjPic_Launcher_Gun, + ObjPic_Quad, + ObjPic_Trike, + ObjPic_Harvester, + ObjPic_Harvester_Sand, + ObjPic_MCV, + ObjPic_Carryall, + ObjPic_Frigate, + ObjPic_Ornithopter, + ObjPic_Trooper, + ObjPic_Infantry, + ObjPic_Saboteur, + ObjPic_Sandworm, + ObjPic_ConstructionYard, + ObjPic_Windtrap, + ObjPic_Refinery, + ObjPic_Barracks, + ObjPic_WOR, + ObjPic_Radar, + ObjPic_LightFactory, + ObjPic_Silo, + ObjPic_HeavyFactory, + ObjPic_HighTechFactory, + ObjPic_IX, + ObjPic_Palace, + ObjPic_RepairYard, + ObjPic_Starport, + ObjPic_GunTurret, + ObjPic_RocketTurret, + ObjPic_Wall, + ObjPic_Bullet_SmallRocket, + ObjPic_Bullet_MediumRocket, + ObjPic_Bullet_LargeRocket, + ObjPic_Bullet_Small, + ObjPic_Bullet_Medium, + ObjPic_Bullet_Sonic, + ObjPic_Hit_Gas, + ObjPic_Hit_Shell, + ObjPic_ExplosionSmall, + ObjPic_ExplosionMedium1, + ObjPic_ExplosionMedium2, + ObjPic_ExplosionLarge1, + ObjPic_ExplosionLarge2, + ObjPic_ExplosionSmallUnit, + ObjPic_DeadInfantry, + ObjPic_Smoke, + ObjPic_SandwormShimmerMask, + ObjPic_Terrain, + ObjPic_RockDamage, + ObjPic_SandDamage, + ObjPic_Terrain_Hidden, + NUM_OBJPICS +} ObjPic_enum; #define GROUNDUNIT_ROW(i) (i+2)|TILE_NORMAL,(i+1)|TILE_NORMAL,i|TILE_NORMAL,(i+1)|TILE_FLIPV,(i+2)|TILE_FLIPV,(i+3)|TILE_FLIPV, (i+4)|TILE_NORMAL,(i+3)|TILE_NORMAL #define AIRUNIT_ROW(i) (i+2)|TILE_NORMAL,(i+1)|TILE_NORMAL,i|TILE_NORMAL,(i+1)|TILE_FLIPV,(i+2)|TILE_FLIPV,(i+1)|TILE_ROTATE, i|TILE_FLIPH,(i+1)|TILE_FLIPH @@ -89,6 +93,227 @@ (i+4)|TILE_FLIPV,(i+3)|TILE_ROTATE,(i+2)|TILE_ROTATE, (i+1)|TILE_ROTATE,i|TILE_FLIPH,(i+1)|TILE_FLIPH,(i+2)|TILE_FLIPH,(i+3)|TILE_FLIPH +// SmallDetailPics +typedef enum { + Picture_Barracks, + Picture_ConstructionYard, + Picture_Carryall, + Picture_Devastator, + Picture_Deviator, + Picture_DeathHand, + Picture_Fremen, + Picture_GunTurret, + Picture_Harvester, + Picture_HeavyFactory, + Picture_HighTechFactory, + Picture_Infantry, + Picture_IX, + Picture_Launcher, + Picture_LightFactory, + Picture_MCV, + Picture_Ornithopter, + Picture_Palace, + Picture_Quad, + Picture_Radar, + Picture_Raider, + Picture_Refinery, + Picture_RepairYard, + Picture_RocketTurret, + Picture_Saboteur, + Picture_Sardaukar, + Picture_SiegeTank, + Picture_Silo, + Picture_Slab1, + Picture_Slab4, + Picture_SonicTank, + Picture_StarPort, + Picture_Tank, + Picture_Trike, + Picture_Trooper, + Picture_Wall, + Picture_WindTrap, + Picture_WOR, + NUM_SMALLDETAILPICS +} SmallDetailPics_Enum; + +// UI Graphics +typedef enum { + UI_RadarAnimation, + UI_CursorShape, + UI_CreditsDigits, + UI_GameBar, + UI_Indicator, + UI_InvalidPlace, + UI_ValidPlace, + UI_MenuBackground, + UI_Background, + UI_SelectionBox, + UI_TopBar, + UI_ButtonUp, + UI_ButtonUp_Pressed, + UI_ButtonDown, + UI_ButtonDown_Pressed, + UI_MessageBox, + UI_Mentat, + UI_Mentat_Pressed, + UI_Options, + UI_Options_Pressed, + UI_Upgrade, + UI_Upgrade_Pressed, + UI_Repair, + UI_Repair_Pressed, + UI_Difficulty, + UI_HeraldAtre_Coloured, + UI_HeraldHark_Coloured, + UI_HeraldOrd_Coloured, + UI_Dif_Easy, + UI_Dif_Hard, + UI_Dif_Medium, + UI_Minus, + UI_Minus_Pressed, + UI_Plus, + UI_Plus_Pressed, + UI_HouseSelect, + UI_MissionSelect, + UI_OptionsMenu, + UI_LoadSaveWindow, + UI_GameMenu, + UI_HouseChoiceBackground, + UI_MentatBackground, + UI_MentatYes, + UI_MentatYes_Pressed, + UI_MentatNo, + UI_MentatNo_Pressed, + UI_MentatExit, + UI_MentatExit_Pressed, + UI_MentatProcced, + UI_MentatProcced_Pressed, + UI_MentatRepeat, + UI_MentatRepeat_Pressed, + UI_PlanetBackground, + UI_MenuButtonBorder, + UI_DuneLegacy, + UI_MapChoiceScreen, + UI_MapChoiceMapOnly, + UI_MapChoiceMap, + UI_MapChoiceClickMap, + NUM_UIGRAPHICS +} UIGraphics_Enum; + +//Animation +typedef enum { + Anim_AtreidesEyes, + Anim_AtreidesMouth, + Anim_AtreidesShoulder, + Anim_AtreidesBook, + Anim_HarkonnenEyes, + Anim_HarkonnenMouth, + Anim_HarkonnenShoulder, + Anim_OrdosEyes, + Anim_OrdosMouth, + Anim_OrdosShoulder, + Anim_OrdosRing, + Anim_AtreidesPlanet, + Anim_HarkonnenPlanet, + Anim_OrdosPlanet, + Anim_Win1, + Anim_Win2, + Anim_Lose1, + Anim_Lose2, + Anim_Barracks, + Anim_Carryall, + Anim_ConstructionYard, + Anim_Fremen, + Anim_DeathHand, + Anim_Devastator, + Anim_Harvester, + Anim_Radar, + Anim_HighTechFactory, + Anim_SiegeTank, + Anim_HeavyFactory, + Anim_Trooper, + Anim_Infantry, + Anim_IX, + Anim_LightFactory, + Anim_Tank, + Anim_MCV, + Anim_Deviator, + Anim_Ornithopter, + Anim_Raider, + Anim_Palace, + Anim_Quad, + Anim_Refinery, + Anim_RepairYard, + Anim_Launcher, + Anim_RocketTurret, + Anim_Saboteur, + Anim_Slab1, + Anim_SonicTank, + Anim_StarPort, + Anim_Silo, + Anim_Trike, + Anim_GunTurret, + Anim_Wall, + Anim_WindTrap, + Anim_WOR, + Anim_Sandworm, + Anim_Sardaukar, + Anim_Frigate, + Anim_Slab4, + NUM_ANIMATION +} Animation_enum; + +// Voice +typedef enum { + HarvesterDeployed, + ConstructionComplete, + VehicleRepaired, + FrigateHasArrived, + YourMissionIsComplete, + YouHaveFailedYourMission, + RadarActivated, + RadarDeactivated, + NUM_VOICE +} Voice_enum; + +// Sound +typedef enum { + YesSir, + Reporting, + Acknowledged, + Affirmative, + MovingOut, + InfantryOut, + SomethingUnderTheSand, + HouseAtreides, + HouseOrdos, + HouseHarkonnen, + PlaceStructure, + ButtonClick, + InvalidAction, + CreditsTick, + RadarNoise, + Sound_ExplosionGas, + Sound_ExplosionTiny, + Sound_ExplosionSmall, + Sound_ExplosionMedium, + Sound_ExplosionLarge, + Sound_ExplosionStructure, + Sound_WormAttack, + Sound_Gun, + Sound_Rocket, + Sound_Bloom, + Sound_Scream1, + Sound_Scream2, + Sound_Scream3, + Sound_Scream4, + Sound_Scream5, + Sound_MachineGun, + Sound_Sonic, + Sound_RocketSmall, + NUM_SOUNDCHUNK +} Sound_enum; + typedef std::map <unsigned, ImagePtr> images; typedef std::vector <images*> remapped_images; //One for each house @@ -101,10 +326,12 @@ ~DataCache(); public: - void addObjImg(unsigned ID, SDL_Surface * tmp); - ImagePtr getObjImg(unsigned ID, unsigned house = HOUSE_HARKONNEN); + void addObjPic(unsigned ID, SDL_Surface * tmp); + void addVoice(unsigned ID, std::string vocFile); + ImagePtr getObjPic(unsigned ID, unsigned house = HOUSE_HARKONNEN); + private: - bool addObjImg(unsigned ID) { return false;}; + bool addObjPic(unsigned ID) { return false;}; remapped_images m_objImg; remapped_images m_guiImg; }; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dv...@us...> - 2008-04-20 19:07:09
|
Revision: 146 http://dunelegacy.svn.sourceforge.net/dunelegacy/?rev=146&view=rev Author: dvalin Date: 2008-04-20 12:07:01 -0700 (Sun, 20 Apr 2008) Log Message: ----------- fix build of pakview as well as add some more media from richie's branch Modified Paths: -------------- branches/dunks/src/DataCache.cpp branches/dunks/src/pakview.cpp Modified: branches/dunks/src/DataCache.cpp =================================================================== --- branches/dunks/src/DataCache.cpp 2008-04-19 16:22:39 UTC (rev 145) +++ branches/dunks/src/DataCache.cpp 2008-04-20 19:07:01 UTC (rev 146) @@ -37,73 +37,73 @@ //UNITS, BUILDINGS, EXPLOSIONS, and everything that's on the map - addObjImg(ObjImg_Tank_Base, units2->getPictureArray(8,1,GROUNDUNIT_ROW(0))); - addObjImg(ObjImg_Tank_Gun, units2->getPictureArray(8,1,GROUNDUNIT_ROW(5))); - addObjImg(ObjImg_Siegetank_Base, units2->getPictureArray(8,1,GROUNDUNIT_ROW(10))); - addObjImg(ObjImg_Siegetank_Gun, units2->getPictureArray(8,1,GROUNDUNIT_ROW(15))); - addObjImg(ObjImg_Devastator_Base, units2->getPictureArray(8,1,GROUNDUNIT_ROW(20))); - addObjImg(ObjImg_Devastator_Gun, units2->getPictureArray(8,1,GROUNDUNIT_ROW(25))); - addObjImg(ObjImg_Sonictank_Gun, units2->getPictureArray(8,1,GROUNDUNIT_ROW(30))); - addObjImg(ObjImg_Launcher_Gun, units2->getPictureArray(8,1,GROUNDUNIT_ROW(35))); - addObjImg(ObjImg_Quad, units->getPictureArray(8,1,GROUNDUNIT_ROW(0))); - addObjImg(ObjImg_Trike, units->getPictureArray(8,1,GROUNDUNIT_ROW(5))); - addObjImg(ObjImg_Harvester, units->getPictureArray(8,1,GROUNDUNIT_ROW(10))); - addObjImg(ObjImg_Harvester_Sand, units1->getPictureArray(8,3,HARVESTERSAND_ROW(72),HARVESTERSAND_ROW(73),HARVESTERSAND_ROW(74))); - addObjImg(ObjImg_MCV, units->getPictureArray(8,1,GROUNDUNIT_ROW(15))); - addObjImg(ObjImg_Carryall, units->getPictureArray(8,2,AIRUNIT_ROW(45),AIRUNIT_ROW(48))); - addObjImg(ObjImg_Frigate, units->getPictureArray(8,1,AIRUNIT_ROW(60))); - addObjImg(ObjImg_Ornithopter, units->getPictureArray(8,3,ORNITHOPTER_ROW(51),ORNITHOPTER_ROW(52),ORNITHOPTER_ROW(53))); - addObjImg(ObjImg_Trooper, units->getPictureArray(4,3,INFANTRY_ROW(82),INFANTRY_ROW(83),INFANTRY_ROW(84))); - addObjImg(ObjImg_Infantry, units->getPictureArray(4,3,INFANTRY_ROW(73),INFANTRY_ROW(74),INFANTRY_ROW(75))); - addObjImg(ObjImg_Saboteur, units->getPictureArray(4,3,INFANTRY_ROW(63),INFANTRY_ROW(64),INFANTRY_ROW(65))); - addObjImg(ObjImg_Sandworm, units1->getPictureArray(1,5,67|TILE_NORMAL,68|TILE_NORMAL,69|TILE_NORMAL,70|TILE_NORMAL,71|TILE_NORMAL)); - addObjImg(ObjImg_ConstructionYard, icon->getPictureArray(17)); - addObjImg(ObjImg_Windtrap, icon->getPictureArray(19)); - addObjImg(ObjImg_Refinery, icon->getPictureArray(21)); - addObjImg(ObjImg_Barracks, icon->getPictureArray(18)); - addObjImg(ObjImg_WOR, icon->getPictureArray(16)); - addObjImg(ObjImg_Radar, icon->getPictureArray(26)); - addObjImg(ObjImg_LightFactory, icon->getPictureArray(12)); - addObjImg(ObjImg_Silo, icon->getPictureArray(25)); - addObjImg(ObjImg_HeavyFactory, icon->getPictureArray(13)); - addObjImg(ObjImg_HighTechFactory, icon->getPictureArray(14)); - addObjImg(ObjImg_IX, icon->getPictureArray(15)); - addObjImg(ObjImg_Palace, icon->getPictureArray(11)); - addObjImg(ObjImg_RepairYard, icon->getPictureArray(22)); - addObjImg(ObjImg_Starport, icon->getPictureArray(20)); - addObjImg(ObjImg_GunTurret, icon->getPictureArray(23)); - addObjImg(ObjImg_RocketTurret, icon->getPictureArray(24)); - addObjImg(ObjImg_Wall, icon->getPictureArray(6,1,1,75)); - addObjImg(ObjImg_Bullet_SmallRocket, units->getPictureArray(16,1,ROCKET_ROW(35))); - addObjImg(ObjImg_Bullet_MediumRocket, units->getPictureArray(16,1,ROCKET_ROW(20))); - addObjImg(ObjImg_Bullet_LargeRocket, units->getPictureArray(16,1,ROCKET_ROW(40))); - addObjImg(ObjImg_Bullet_Small, units1->getPicture(23)); - addObjImg(ObjImg_Bullet_Medium, units1->getPicture(24)); - addObjImg(ObjImg_Bullet_Sonic, units1->getPicture(9)); - addObjImg(ObjImg_Hit_Gas, units1->getPictureArray(5,1,57|TILE_NORMAL,58|TILE_NORMAL,59|TILE_NORMAL,60|TILE_NORMAL,61|TILE_NORMAL)); - addObjImg(ObjImg_Hit_Shell, units1->getPictureArray(3,1,2|TILE_NORMAL,3|TILE_NORMAL,4|TILE_NORMAL)); - addObjImg(ObjImg_ExplosionSmall, units1->getPictureArray(5,1,32|TILE_NORMAL,33|TILE_NORMAL,34|TILE_NORMAL,35|TILE_NORMAL,36|TILE_NORMAL)); - addObjImg(ObjImg_ExplosionMedium1, units1->getPictureArray(5,1,47|TILE_NORMAL,48|TILE_NORMAL,49|TILE_NORMAL,50|TILE_NORMAL,51|TILE_NORMAL)); - addObjImg(ObjImg_ExplosionMedium2, units1->getPictureArray(5,1,52|TILE_NORMAL,53|TILE_NORMAL,54|TILE_NORMAL,55|TILE_NORMAL,56|TILE_NORMAL)); - addObjImg(ObjImg_ExplosionLarge1, units1->getPictureArray(5,1,37|TILE_NORMAL,38|TILE_NORMAL,39|TILE_NORMAL,40|TILE_NORMAL,41|TILE_NORMAL)); - addObjImg(ObjImg_ExplosionLarge2, units1->getPictureArray(5,1,42|TILE_NORMAL,43|TILE_NORMAL,44|TILE_NORMAL,45|TILE_NORMAL,46|TILE_NORMAL)); - addObjImg(ObjImg_ExplosionSmallUnit, units1->getPictureArray(2,1,0|TILE_NORMAL,1|TILE_NORMAL)); - addObjImg(ObjImg_DeadInfantry, icon->getPictureArray(4,1,1,6)); - addObjImg(ObjImg_Smoke, units1->getPictureArray(3,1,29|TILE_NORMAL,30|TILE_NORMAL,31|TILE_NORMAL)); - addObjImg(ObjImg_SandwormShimmerMask, units1->getPicture(10)); - addObjImg(ObjImg_Terrain, icon->getPictureRow(124,209)); - addObjImg(ObjImg_RockDamage, icon->getPictureRow(1,6)); - addObjImg(ObjImg_SandDamage, units1->getPictureArray(3,1,5|TILE_NORMAL,6|TILE_NORMAL,7|TILE_NORMAL)); - addObjImg(ObjImg_Terrain_Hidden, icon->getPictureRow(108,123)); + addObjPic(ObjPic_Tank_Base, units2->getPictureArray(8,1,GROUNDUNIT_ROW(0))); + addObjPic(ObjPic_Tank_Gun, units2->getPictureArray(8,1,GROUNDUNIT_ROW(5))); + addObjPic(ObjPic_Siegetank_Base, units2->getPictureArray(8,1,GROUNDUNIT_ROW(10))); + addObjPic(ObjPic_Siegetank_Gun, units2->getPictureArray(8,1,GROUNDUNIT_ROW(15))); + addObjPic(ObjPic_Devastator_Base, units2->getPictureArray(8,1,GROUNDUNIT_ROW(20))); + addObjPic(ObjPic_Devastator_Gun, units2->getPictureArray(8,1,GROUNDUNIT_ROW(25))); + addObjPic(ObjPic_Sonictank_Gun, units2->getPictureArray(8,1,GROUNDUNIT_ROW(30))); + addObjPic(ObjPic_Launcher_Gun, units2->getPictureArray(8,1,GROUNDUNIT_ROW(35))); + addObjPic(ObjPic_Quad, units->getPictureArray(8,1,GROUNDUNIT_ROW(0))); + addObjPic(ObjPic_Trike, units->getPictureArray(8,1,GROUNDUNIT_ROW(5))); + addObjPic(ObjPic_Harvester, units->getPictureArray(8,1,GROUNDUNIT_ROW(10))); + addObjPic(ObjPic_Harvester_Sand, units1->getPictureArray(8,3,HARVESTERSAND_ROW(72),HARVESTERSAND_ROW(73),HARVESTERSAND_ROW(74))); + addObjPic(ObjPic_MCV, units->getPictureArray(8,1,GROUNDUNIT_ROW(15))); + addObjPic(ObjPic_Carryall, units->getPictureArray(8,2,AIRUNIT_ROW(45),AIRUNIT_ROW(48))); + addObjPic(ObjPic_Frigate, units->getPictureArray(8,1,AIRUNIT_ROW(60))); + addObjPic(ObjPic_Ornithopter, units->getPictureArray(8,3,ORNITHOPTER_ROW(51),ORNITHOPTER_ROW(52),ORNITHOPTER_ROW(53))); + addObjPic(ObjPic_Trooper, units->getPictureArray(4,3,INFANTRY_ROW(82),INFANTRY_ROW(83),INFANTRY_ROW(84))); + addObjPic(ObjPic_Infantry, units->getPictureArray(4,3,INFANTRY_ROW(73),INFANTRY_ROW(74),INFANTRY_ROW(75))); + addObjPic(ObjPic_Saboteur, units->getPictureArray(4,3,INFANTRY_ROW(63),INFANTRY_ROW(64),INFANTRY_ROW(65))); + addObjPic(ObjPic_Sandworm, units1->getPictureArray(1,5,67|TILE_NORMAL,68|TILE_NORMAL,69|TILE_NORMAL,70|TILE_NORMAL,71|TILE_NORMAL)); + addObjPic(ObjPic_ConstructionYard, icon->getPictureArray(17)); + addObjPic(ObjPic_Windtrap, icon->getPictureArray(19)); + addObjPic(ObjPic_Refinery, icon->getPictureArray(21)); + addObjPic(ObjPic_Barracks, icon->getPictureArray(18)); + addObjPic(ObjPic_WOR, icon->getPictureArray(16)); + addObjPic(ObjPic_Radar, icon->getPictureArray(26)); + addObjPic(ObjPic_LightFactory, icon->getPictureArray(12)); + addObjPic(ObjPic_Silo, icon->getPictureArray(25)); + addObjPic(ObjPic_HeavyFactory, icon->getPictureArray(13)); + addObjPic(ObjPic_HighTechFactory, icon->getPictureArray(14)); + addObjPic(ObjPic_IX, icon->getPictureArray(15)); + addObjPic(ObjPic_Palace, icon->getPictureArray(11)); + addObjPic(ObjPic_RepairYard, icon->getPictureArray(22)); + addObjPic(ObjPic_Starport, icon->getPictureArray(20)); + addObjPic(ObjPic_GunTurret, icon->getPictureArray(23)); + addObjPic(ObjPic_RocketTurret, icon->getPictureArray(24)); + addObjPic(ObjPic_Wall, icon->getPictureArray(6,1,1,75)); + addObjPic(ObjPic_Bullet_SmallRocket, units->getPictureArray(16,1,ROCKET_ROW(35))); + addObjPic(ObjPic_Bullet_MediumRocket, units->getPictureArray(16,1,ROCKET_ROW(20))); + addObjPic(ObjPic_Bullet_LargeRocket, units->getPictureArray(16,1,ROCKET_ROW(40))); + addObjPic(ObjPic_Bullet_Small, units1->getPicture(23)); + addObjPic(ObjPic_Bullet_Medium, units1->getPicture(24)); + addObjPic(ObjPic_Bullet_Sonic, units1->getPicture(9)); + addObjPic(ObjPic_Hit_Gas, units1->getPictureArray(5,1,57|TILE_NORMAL,58|TILE_NORMAL,59|TILE_NORMAL,60|TILE_NORMAL,61|TILE_NORMAL)); + addObjPic(ObjPic_Hit_Shell, units1->getPictureArray(3,1,2|TILE_NORMAL,3|TILE_NORMAL,4|TILE_NORMAL)); + addObjPic(ObjPic_ExplosionSmall, units1->getPictureArray(5,1,32|TILE_NORMAL,33|TILE_NORMAL,34|TILE_NORMAL,35|TILE_NORMAL,36|TILE_NORMAL)); + addObjPic(ObjPic_ExplosionMedium1, units1->getPictureArray(5,1,47|TILE_NORMAL,48|TILE_NORMAL,49|TILE_NORMAL,50|TILE_NORMAL,51|TILE_NORMAL)); + addObjPic(ObjPic_ExplosionMedium2, units1->getPictureArray(5,1,52|TILE_NORMAL,53|TILE_NORMAL,54|TILE_NORMAL,55|TILE_NORMAL,56|TILE_NORMAL)); + addObjPic(ObjPic_ExplosionLarge1, units1->getPictureArray(5,1,37|TILE_NORMAL,38|TILE_NORMAL,39|TILE_NORMAL,40|TILE_NORMAL,41|TILE_NORMAL)); + addObjPic(ObjPic_ExplosionLarge2, units1->getPictureArray(5,1,42|TILE_NORMAL,43|TILE_NORMAL,44|TILE_NORMAL,45|TILE_NORMAL,46|TILE_NORMAL)); + addObjPic(ObjPic_ExplosionSmallUnit, units1->getPictureArray(2,1,0|TILE_NORMAL,1|TILE_NORMAL)); + addObjPic(ObjPic_DeadInfantry, icon->getPictureArray(4,1,1,6)); + addObjPic(ObjPic_Smoke, units1->getPictureArray(3,1,29|TILE_NORMAL,30|TILE_NORMAL,31|TILE_NORMAL)); + addObjPic(ObjPic_SandwormShimmerMask, units1->getPicture(10)); + addObjPic(ObjPic_Terrain, icon->getPictureRow(124,209)); + addObjPic(ObjPic_RockDamage, icon->getPictureRow(1,6)); + addObjPic(ObjPic_SandDamage, units1->getPictureArray(3,1,5|TILE_NORMAL,6|TILE_NORMAL,7|TILE_NORMAL)); + addObjPic(ObjPic_Terrain_Hidden, icon->getPictureRow(108,123)); } -void DataCache::addObjImg(unsigned ID, SDL_Surface * tmp) { +void DataCache::addObjPic(unsigned ID, SDL_Surface * tmp) { m_objImg[HOUSE_HARKONNEN]->insert(pair<unsigned, ImagePtr>(ID, ImagePtr(new Image(tmp)))); } -ImagePtr DataCache::getObjImg(unsigned ID, unsigned house) { +ImagePtr DataCache::getObjPic(unsigned ID, unsigned house) { images::iterator iter = m_objImg[house]->find(ID); if (iter != m_objImg[house]->end()) @@ -120,6 +120,10 @@ } +/*void DataCache::addVoice(unsigned ID, std::string){ + +}*/ + DataCache::~DataCache() { } Modified: branches/dunks/src/pakview.cpp =================================================================== --- branches/dunks/src/pakview.cpp 2008-04-19 16:22:39 UTC (rev 145) +++ branches/dunks/src/pakview.cpp 2008-04-20 19:07:01 UTC (rev 146) @@ -26,7 +26,7 @@ public: PakViewState() { - img = ObjImg_Terrain; + img = ObjPic_Terrain; house = HOUSE_ATREIDES; m_button = new BoringButton("Click me, bitte!"); m_button->setSize(SPoint(160, 50)); @@ -42,7 +42,7 @@ m_houseBut->onClick.connect( boost::bind(&PakViewState::SwitchHouse, this) ); - m_test = DataCache::Instance()->getObjImg(img, house); + m_test = DataCache::Instance()->getObjPic(img, house); Application::Instance()->RootWidget()->addChild(m_button); Application::Instance()->RootWidget()->addChild(m_houseBut); @@ -64,10 +64,10 @@ { img++; - if (img == NUM_OBJIMGS) - img = 0; + if (img == NUM_OBJPICS) + img = 0; - m_test = DataCache::Instance()->getObjImg(img, house); + m_test = DataCache::Instance()->getObjPic(img, house); }; void SwitchHouse() @@ -75,8 +75,8 @@ house++; fprintf(stderr, "HOUSE CHANGED\n"); if (house == NUM_HOUSES) - house = 0; - m_test = DataCache::Instance()->getObjImg(img, house); + house = 0; + m_test = DataCache::Instance()->getObjPic(img, house); }; virtual const char* GetName() { return "PakViewState"; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dv...@us...> - 2008-04-19 16:22:45
|
Revision: 145 http://dunelegacy.svn.sourceforge.net/dunelegacy/?rev=145&view=rev Author: dvalin Date: 2008-04-19 09:22:39 -0700 (Sat, 19 Apr 2008) Log Message: ----------- convert to unix style eol Modified Paths: -------------- branches/dunks/src/ResMan.cpp Modified: branches/dunks/src/ResMan.cpp =================================================================== --- branches/dunks/src/ResMan.cpp 2008-04-17 18:53:03 UTC (rev 144) +++ branches/dunks/src/ResMan.cpp 2008-04-19 16:22:39 UTC (rev 145) @@ -1,312 +1,312 @@ -#include "boost/filesystem/path.hpp" -#include "boost/filesystem/operations.hpp" -#include "boost/format.hpp" - -#include <fstream> -#include <sstream> -#include <iostream> - -#include "ResMan.h" -#include "Settings.h" -//#include "Log.h" - -//#include "boost/filesystem/fstream.hpp" // ditto - -#include <assert.h> - -namespace bfs = boost::filesystem; - -FileLike::FileLike(unsigned char* buf, int size) -{ - m_buf = buf; - m_size = size; - m_pos = 0; -} - -FileLike::~FileLike() -{ - delete m_buf; -} - -void FileLike::read(void* buf, int size) -{ - memcpy(buf, &m_buf[m_pos], size); - m_pos += size; -} - -void FileLike::seek(int offset) -{ - m_pos = offset; -} - -// ------------------------------------------------------------------ - -Resource::Resource() -{ - mb_writable = false; -} - -Resource::~Resource() -{ - -} - -// ------------------------------------------------------------------ - -DIRResource::DIRResource(bfs::path path) -{ - m_path = path; -} - -unsigned char* DIRResource::readFile(std::string path, int *size) -{ - bfs::path fullpath (m_path); - fullpath /= path; - - FILE *file = fopen (fullpath.string().c_str(), "rb"); - fseek(file, 0, SEEK_END); - int filesize = ftell(file); - - fseek(file, 0, SEEK_SET); - - unsigned char* buf = new unsigned char[filesize]; - - fread(buf, filesize, 1, file); - - fclose(file); - - if (size != NULL) *size = filesize; - - return buf; -} - -std::string DIRResource::readText(std::string path) -{ - bfs::path fullpath (m_path); - fullpath /= path; - std::string file_contents; - printf("opening file %s...\n", fullpath.string().c_str()); - std::ifstream file_stream(fullpath.string().c_str()); - - assert( file_stream.is_open() ); - - std::stringstream temp; - temp << file_stream.rdbuf(); - - file_contents = temp.str(); - //std::cout << file_contents << std::endl; - - return file_contents; -} - -bool DIRResource::exists(std::string path) -{ - bfs::path fullpath(m_path); - fullpath /= path; - return bfs::exists(fullpath); -} - -// ------------------------------------------------------------------ - -WritableDIRResource::WritableDIRResource(std::string path) : DIRResource(path) -{ - mb_writable = true; -} - -void WritableDIRResource::writeText(std::string path, std::string text) -{ - bfs::path fullpath(m_path); - fullpath /= path; - - std::ofstream file; - file.open(fullpath.string().c_str()); - file << text; - file.close(); -} - -// ------------------------------------------------------------------ - -PAKResource::PAKResource(bfs::path path) -{ - m_path = path; - m_pakfile = new Pakfile(path.string().c_str()); -} - -PAKResource::~PAKResource() -{ - delete m_pakfile; -} - -unsigned char* PAKResource::readFile(std::string path, int *size) -{ - int filesize; - unsigned char *buf = m_pakfile->getFile(path.c_str(), &filesize); - - //RESMAN_LOG_INFO(boost::format("read pak %s size %d\n") % path.string().c_str() % filesize); - - assert(buf != NULL); - assert(filesize != 0); - - if (size != NULL) *size = filesize; - - return buf; -} - -bool PAKResource::exists(std::string path) -{ - for (int i=0; i!= m_pakfile->getNumFiles(); i++) - { - if (m_pakfile->getFilename(i) == path) return true; - }; - return false; -} - -// ------------------------------------------------------------------ - -ResMan::ResMan() -{ - -} - -ResMan::~ResMan() -{ - ResList::iterator it; - for (it = m_resources.begin(); - it != m_resources.end(); - ++it) - { - delete (it->second); - }; - - m_resources.clear(); -} - -bool ResMan::addRes(std::string name) -{ - std::string fullpath = Settings::Instance()->GetDataDir(); - fullpath.append(name); - printf("adding resource %s from %s...\n", name.c_str(), fullpath.c_str()); - bfs::path file (fullpath); - Resource *res = NULL; - - if (bfs::exists(file)) - { - printf("Using DIRResource for %s\n", name.c_str()); - res = new DIRResource(file); - } - else - { - std::string pakname = file.string(); - pakname.append(".PAK"); - bfs::path pakpath (pakname); - - if (!bfs::exists(pakpath)) - { - printf("Neither DIR or PAK found for %s\n", name.c_str()); - return false; - } - - res = new PAKResource(pakpath); - }; - - return addRes(name, res); -} - -bool ResMan::addRes(std::string name, Resource *res) -{ - m_resources[name.c_str()] = res; - - return true; -} - -Resource* ResMan::getResource(std::string name, std::string& filename) -{ - unsigned int p = name.find(':'); - assert(p != std::string::npos); - - std::string fsname = std::string(name, 0, p); - filename = std::string(name, p+1, name.length() - fsname.length() - 1); - - printf("opening file from %s named %s...\n", fsname.c_str(), filename.c_str()); - - Resource* res = m_resources[fsname]; - - if (res == NULL) - { - printf("ERROR: cannot find file!\n"); - - return NULL; - }; - - return res; -} - -bool ResMan::exists(std::string path) -{ - std::string filename; - Resource* res = getResource(path, filename); - - if (res == NULL) - { - return false; - }; - - return res->exists(filename); -} - -unsigned char* ResMan::readFile(std::string name, int *size) -{ - std::string filename; - Resource* res = getResource(name, filename); - - if (res == NULL) - { +#include "boost/filesystem/path.hpp" +#include "boost/filesystem/operations.hpp" +#include "boost/format.hpp" + +#include <fstream> +#include <sstream> +#include <iostream> + +#include "ResMan.h" +#include "Settings.h" +//#include "Log.h" + +//#include "boost/filesystem/fstream.hpp" // ditto + +#include <assert.h> + +namespace bfs = boost::filesystem; + +FileLike::FileLike(unsigned char* buf, int size) +{ + m_buf = buf; + m_size = size; + m_pos = 0; +} + +FileLike::~FileLike() +{ + delete m_buf; +} + +void FileLike::read(void* buf, int size) +{ + memcpy(buf, &m_buf[m_pos], size); + m_pos += size; +} + +void FileLike::seek(int offset) +{ + m_pos = offset; +} + +// ------------------------------------------------------------------ + +Resource::Resource() +{ + mb_writable = false; +} + +Resource::~Resource() +{ + +} + +// ------------------------------------------------------------------ + +DIRResource::DIRResource(bfs::path path) +{ + m_path = path; +} + +unsigned char* DIRResource::readFile(std::string path, int *size) +{ + bfs::path fullpath (m_path); + fullpath /= path; + + FILE *file = fopen (fullpath.string().c_str(), "rb"); + fseek(file, 0, SEEK_END); + int filesize = ftell(file); + + fseek(file, 0, SEEK_SET); + + unsigned char* buf = new unsigned char[filesize]; + + fread(buf, filesize, 1, file); + + fclose(file); + + if (size != NULL) *size = filesize; + + return buf; +} + +std::string DIRResource::readText(std::string path) +{ + bfs::path fullpath (m_path); + fullpath /= path; + std::string file_contents; + printf("opening file %s...\n", fullpath.string().c_str()); + std::ifstream file_stream(fullpath.string().c_str()); + + assert( file_stream.is_open() ); + + std::stringstream temp; + temp << file_stream.rdbuf(); + + file_contents = temp.str(); + //std::cout << file_contents << std::endl; + + return file_contents; +} + +bool DIRResource::exists(std::string path) +{ + bfs::path fullpath(m_path); + fullpath /= path; + return bfs::exists(fullpath); +} + +// ------------------------------------------------------------------ + +WritableDIRResource::WritableDIRResource(std::string path) : DIRResource(path) +{ + mb_writable = true; +} + +void WritableDIRResource::writeText(std::string path, std::string text) +{ + bfs::path fullpath(m_path); + fullpath /= path; + + std::ofstream file; + file.open(fullpath.string().c_str()); + file << text; + file.close(); +} + +// ------------------------------------------------------------------ + +PAKResource::PAKResource(bfs::path path) +{ + m_path = path; + m_pakfile = new Pakfile(path.string().c_str()); +} + +PAKResource::~PAKResource() +{ + delete m_pakfile; +} + +unsigned char* PAKResource::readFile(std::string path, int *size) +{ + int filesize; + unsigned char *buf = m_pakfile->getFile(path.c_str(), &filesize); + + //RESMAN_LOG_INFO(boost::format("read pak %s size %d\n") % path.string().c_str() % filesize); + + assert(buf != NULL); + assert(filesize != 0); + + if (size != NULL) *size = filesize; + + return buf; +} + +bool PAKResource::exists(std::string path) +{ + for (int i=0; i!= m_pakfile->getNumFiles(); i++) + { + if (m_pakfile->getFilename(i) == path) return true; + }; + return false; +} + +// ------------------------------------------------------------------ + +ResMan::ResMan() +{ + +} + +ResMan::~ResMan() +{ + ResList::iterator it; + for (it = m_resources.begin(); + it != m_resources.end(); + ++it) + { + delete (it->second); + }; + + m_resources.clear(); +} + +bool ResMan::addRes(std::string name) +{ + std::string fullpath = Settings::Instance()->GetDataDir(); + fullpath.append(name); + printf("adding resource %s from %s...\n", name.c_str(), fullpath.c_str()); + bfs::path file (fullpath); + Resource *res = NULL; + + if (bfs::exists(file)) + { + printf("Using DIRResource for %s\n", name.c_str()); + res = new DIRResource(file); + } + else + { + std::string pakname = file.string(); + pakname.append(".PAK"); + bfs::path pakpath (pakname); + + if (!bfs::exists(pakpath)) + { + printf("Neither DIR or PAK found for %s\n", name.c_str()); + return false; + } + + res = new PAKResource(pakpath); + }; + + return addRes(name, res); +} + +bool ResMan::addRes(std::string name, Resource *res) +{ + m_resources[name.c_str()] = res; + + return true; +} + +Resource* ResMan::getResource(std::string name, std::string& filename) +{ + unsigned int p = name.find(':'); + assert(p != std::string::npos); + + std::string fsname = std::string(name, 0, p); + filename = std::string(name, p+1, name.length() - fsname.length() - 1); + + printf("opening file from %s named %s...\n", fsname.c_str(), filename.c_str()); + + Resource* res = m_resources[fsname]; + + if (res == NULL) + { + printf("ERROR: cannot find file!\n"); + + return NULL; + }; + + return res; +} + +bool ResMan::exists(std::string path) +{ + std::string filename; + Resource* res = getResource(path, filename); + + if (res == NULL) + { + return false; + }; + + return res->exists(filename); +} + +unsigned char* ResMan::readFile(std::string name, int *size) +{ + std::string filename; + Resource* res = getResource(name, filename); + + if (res == NULL) + { if (size != NULL) size = 0; - return NULL; + return NULL; }; - unsigned char *buf = res->readFile(filename.c_str(), size); - - assert(buf != NULL); + unsigned char *buf = res->readFile(filename.c_str(), size); + assert(buf != NULL); + return buf; -} - -FileLike* ResMan::readFile(std::string name) -{ - int size; - unsigned char* buf = readFile(name, &size); - return new FileLike(buf, size); -} - -std::string ResMan::readText(std::string name) -{ - std::string filename; - Resource* res = getResource(name, filename); - if (res == NULL) return ""; - - assert(res != NULL); - - return res->readText(filename); -} - -void ResMan::writeText(std::string name, std::string text) -{ - std::string filename; - Resource* res = getResource(name, filename); - if (res == NULL) - { - printf("resource not found!\n"); - assert(0); - return; - }; - - if (!res->isWritable()) - { - printf("resource not writable!\n"); - assert(0); - return; - }; - - res->writeText(filename, text); -} +} + +FileLike* ResMan::readFile(std::string name) +{ + int size; + unsigned char* buf = readFile(name, &size); + return new FileLike(buf, size); +} + +std::string ResMan::readText(std::string name) +{ + std::string filename; + Resource* res = getResource(name, filename); + if (res == NULL) return ""; + + assert(res != NULL); + + return res->readText(filename); +} + +void ResMan::writeText(std::string name, std::string text) +{ + std::string filename; + Resource* res = getResource(name, filename); + if (res == NULL) + { + printf("resource not found!\n"); + assert(0); + return; + }; + + if (!res->isWritable()) + { + printf("resource not writable!\n"); + assert(0); + return; + }; + + res->writeText(filename, text); +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dv...@us...> - 2008-04-17 18:53:13
|
Revision: 144 http://dunelegacy.svn.sourceforge.net/dunelegacy/?rev=144&view=rev Author: dvalin Date: 2008-04-17 11:53:03 -0700 (Thu, 17 Apr 2008) Log Message: ----------- pass SDL_Surface for m_screen to SDL_FillRect Modified Paths: -------------- branches/dunks/src/Application.cpp Modified: branches/dunks/src/Application.cpp =================================================================== --- branches/dunks/src/Application.cpp 2008-04-17 18:31:13 UTC (rev 143) +++ branches/dunks/src/Application.cpp 2008-04-17 18:53:03 UTC (rev 144) @@ -375,7 +375,7 @@ for (Uint32 i=0; i!=256; i++) { pdest.x = 7 * i; - SDL_FillRect(m_screen, &pdest, i); + SDL_FillRect(m_screen->getSurface(), &pdest, i); } #endif This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dv...@us...> - 2008-04-17 18:31:19
|
Revision: 143 http://dunelegacy.svn.sourceforge.net/dunelegacy/?rev=143&view=rev Author: dvalin Date: 2008-04-17 11:31:13 -0700 (Thu, 17 Apr 2008) Log Message: ----------- fix deprecated conversion from string constant to 'char*' Modified Paths: -------------- branches/dunks/src/Application.cpp Modified: branches/dunks/src/Application.cpp =================================================================== --- branches/dunks/src/Application.cpp 2008-04-17 18:21:01 UTC (rev 142) +++ branches/dunks/src/Application.cpp 2008-04-17 18:31:13 UTC (rev 143) @@ -365,8 +365,8 @@ BlitCursor(); #if 0 - fnt->render("ABCDEFGHIJKLMOPQRSTUVWXYZ", m_screen, 10, 10, gpaloff); - fnt->render("abcdefghijklmnopqrstuvwxz", m_screen, 10, 30, gpaloff); + fnt->render((const char*)"ABCDEFGHIJKLMOPQRSTUVWXYZ", m_screen, 10, 10, gpaloff); + fnt->render((const char*)"abcdefghijklmnopqrstuvwxz", m_screen, 10, 30, gpaloff); #endif #if 0 This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dv...@us...> - 2008-04-17 18:21:06
|
Revision: 142 http://dunelegacy.svn.sourceforge.net/dunelegacy/?rev=142&view=rev Author: dvalin Date: 2008-04-17 11:21:01 -0700 (Thu, 17 Apr 2008) Log Message: ----------- call Die() to ensure that program quits properly Modified Paths: -------------- branches/dunks/src/Application.cpp Modified: branches/dunks/src/Application.cpp =================================================================== --- branches/dunks/src/Application.cpp 2008-04-17 18:05:50 UTC (rev 141) +++ branches/dunks/src/Application.cpp 2008-04-17 18:21:01 UTC (rev 142) @@ -395,6 +395,7 @@ }; printf("done\n"); + Die(); } void Application::HandleEvents() This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dv...@us...> - 2008-04-17 18:06:12
|
Revision: 141 http://dunelegacy.svn.sourceforge.net/dunelegacy/?rev=141&view=rev Author: dvalin Date: 2008-04-17 11:05:50 -0700 (Thu, 17 Apr 2008) Log Message: ----------- fix deprecated conversion from string constant to 'char*' Modified Paths: -------------- branches/dunks/include/Settings.h branches/dunks/src/Settings.cpp Modified: branches/dunks/include/Settings.h =================================================================== --- branches/dunks/include/Settings.h 2008-04-17 18:04:51 UTC (rev 140) +++ branches/dunks/include/Settings.h 2008-04-17 18:05:50 UTC (rev 141) @@ -79,7 +79,7 @@ void load(); void save(); - void ParseFile(char* fn); + void ParseFile(const char* fn); void ParseOptions(int argc, char* argv[]); inline int GetWidth() Modified: branches/dunks/src/Settings.cpp =================================================================== --- branches/dunks/src/Settings.cpp 2008-04-17 18:04:51 UTC (rev 140) +++ branches/dunks/src/Settings.cpp 2008-04-17 18:05:50 UTC (rev 141) @@ -64,7 +64,7 @@ ResMan::Instance()->writeText("CONFIG:config.txt", configText); } -void Settings::ParseFile(char* fn) +void Settings::ParseFile(const char* fn) { /* ifstream file(fn); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dv...@us...> - 2008-04-17 18:05:03
|
Revision: 140 http://dunelegacy.svn.sourceforge.net/dunelegacy/?rev=140&view=rev Author: dvalin Date: 2008-04-17 11:04:51 -0700 (Thu, 17 Apr 2008) Log Message: ----------- comment out log function that's broken and not used Modified Paths: -------------- branches/dunks/src/Log.cpp Modified: branches/dunks/src/Log.cpp =================================================================== --- branches/dunks/src/Log.cpp 2008-04-17 17:28:53 UTC (rev 139) +++ branches/dunks/src/Log.cpp 2008-04-17 18:04:51 UTC (rev 140) @@ -36,11 +36,11 @@ //------------------------------------------------------------------------------ // Log class //------------------------------------------------------------------------------ - + /* void Log::log(ConstString logSystem, LogVerbosity verbosity, ConstString message) { doLog(logSystem, verbosity, "%s", (char *)message.c_str()); -} +}*/ void Log::log(ConstString logSystem, LogVerbosity verbosity, const char *format, ...) { va_list args; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dv...@us...> - 2008-04-17 17:23:35
|
Revision: 138 http://dunelegacy.svn.sourceforge.net/dunelegacy/?rev=138&view=rev Author: dvalin Date: 2008-04-17 10:22:35 -0700 (Thu, 17 Apr 2008) Log Message: ----------- fix deprecated conversion from string constant to 'char*' Modified Paths: -------------- trunk/include/MapGenerator.h trunk/include/Mentat.h trunk/include/MentatClass.h trunk/include/Menu.h trunk/include/gui/Button.h trunk/include/gui/Entry.h trunk/include/gui/Graphics.h trunk/include/gui/Label.h trunk/src/Game.cpp trunk/src/MapGenerator.cpp trunk/src/Mentat.cpp trunk/src/MentatClass.cpp trunk/src/Menu.cpp trunk/src/editor.cpp trunk/src/gui/Button.cpp trunk/src/gui/Entry.cpp trunk/src/gui/Graphics.cpp trunk/src/gui/Label.cpp Modified: trunk/include/MapGenerator.h =================================================================== --- trunk/include/MapGenerator.h 2008-04-17 17:17:14 UTC (rev 137) +++ trunk/include/MapGenerator.h 2008-04-17 17:22:35 UTC (rev 138) @@ -8,8 +8,8 @@ void smooth_terrain(); void fixWalls(int xPos, int yPos); void make_random_map(int sizeX, int sizeY, int = SPICEFIELDS, int = ROCKFIELDS); -int readMapPlayerNumbers(char* filename, int numbers[MAX_PLAYERS]); -int readMapMaxPlayers(char* filename); -bool loadMap(char* mapName); +int readMapPlayerNumbers(const char* filename, int numbers[MAX_PLAYERS]); +int readMapMaxPlayers(const char* filename); +bool loadMap(const char* mapName); #endif // DUNE_MAPGENERATOR_H Modified: trunk/include/Mentat.h =================================================================== --- trunk/include/Mentat.h 2008-04-17 17:17:14 UTC (rev 137) +++ trunk/include/Mentat.h 2008-04-17 17:22:35 UTC (rev 138) @@ -146,9 +146,9 @@ { SDL_Surface *staticpic; SDL_Surface **pic; - char *text; - char *fullText[512];//needed? - char *basePath; + const char *text; + const char *fullText[512];//needed? + const char *basePath; int frames; int curFrame; @@ -173,10 +173,10 @@ void handleRelease(int x, int y); void handleCancelRelease(int x, int y); void LoadData(); - void LoadMentatEntry(int entry, int frames, char *basePath, char *text); + void LoadMentatEntry(int entry, int frames, const char *basePath, const char *text); void UnLoadMentatEntry(int entry); void setMentatView(int entry); - char *getFramePath(char *basePath, int frame); + const char *getFramePath(const char *basePath, int frame); void createList(); void checkMinMaxSelection(); @@ -211,7 +211,7 @@ void UnloadTemporaryData(); - SDL_Surface *loadImageFromZip(ZZIP_DIR* zzipdir, char *path); + SDL_Surface *loadImageFromZip(ZZIP_DIR* zzipdir, const char *path); private: Window *mentatWindow; @@ -264,7 +264,7 @@ Window *houseInfoWindow; Label textLabel; - char *zipPath; + const char *zipPath; }; #endif // DUNE_MENTATCLASS_H Modified: trunk/include/MentatClass.h =================================================================== --- trunk/include/MentatClass.h 2008-04-17 17:17:14 UTC (rev 137) +++ trunk/include/MentatClass.h 2008-04-17 17:22:35 UTC (rev 138) @@ -172,10 +172,10 @@ void handleRelease(int x, int y); void handleCancelRelease(int x, int y); void LoadData(); - void LoadMentatEntry(int entry, int frames, char *basePath, char *text); + void LoadMentatEntry(int entry, int frames, const char *basePath, const char *text); void UnLoadMentatEntry(int entry); void setMentatView(int entry); - char *getFramePath(char *basePath, int frame); + const char *getFramePath(const char *basePath, int frame); void createList(); void checkMinMaxSelection(); @@ -210,7 +210,7 @@ void UnloadTemporaryData(); - SDL_Surface *loadImageFromZip(ZZIP_DIR* zzipdir, char *path); + SDL_Surface *loadImageFromZip(ZZIP_DIR* zzipdir, const char *path); private: Window *mentatWindow; Modified: trunk/include/Menu.h =================================================================== --- trunk/include/Menu.h 2008-04-17 17:17:14 UTC (rev 137) +++ trunk/include/Menu.h 2008-04-17 17:22:35 UTC (rev 138) @@ -7,7 +7,7 @@ #include "SDL_thread.h" #include "SDL_net.h" -int houseNameToNum(char* house); +int houseNameToNum(const char* house); #define SCREEN_BPP 8 #define VERSION "0.94.1" @@ -270,7 +270,7 @@ -char* houseName[9] = +const char* houseName[9] = { Modified: trunk/include/gui/Button.h =================================================================== --- trunk/include/gui/Button.h 2008-04-17 17:17:14 UTC (rev 137) +++ trunk/include/gui/Button.h 2008-04-17 17:22:35 UTC (rev 138) @@ -25,10 +25,10 @@ void handleRelease(Uint32 x, Uint32 y); void setSurface(SDL_Surface* newSurface, SDL_Rect* src); void setPressedSurface(SDL_Surface* newSurface, SDL_Rect* src); - void setHelpText(char* newText); - void setText(char* newText); + void setHelpText(const char* newText); + void setText(const char* newText); void setToggled(bool toggle); - bool textEquals(char* checkText); + bool textEquals(const char* checkText); char* getText(); int getProgress(); Modified: trunk/include/gui/Entry.h =================================================================== --- trunk/include/gui/Entry.h 2008-04-17 17:17:14 UTC (rev 137) +++ trunk/include/gui/Entry.h 2008-04-17 17:22:35 UTC (rev 138) @@ -19,10 +19,10 @@ void setCallBackConfirm(void (*newCallback)()); void setEditable(bool truth); void setFocused(bool truth); - void setText(char* newText); - bool textEquals(char* checkText); + void setText(const char* newText); + bool textEquals(const char* checkText); - inline char* getText() { return text; } + inline const char* getText() { return text; } private: bool editable; Modified: trunk/include/gui/Graphics.h =================================================================== --- trunk/include/gui/Graphics.h 2008-04-17 17:17:14 UTC (rev 137) +++ trunk/include/gui/Graphics.h 2008-04-17 17:22:35 UTC (rev 138) @@ -21,7 +21,7 @@ void drawrect(SDL_Surface *surface, int x1, int y1, int x2, int y2, Uint32 colour); -void showMessage(char* newMessage); +void showMessage(const char* newMessage); SDL_Surface* copySurface(SDL_Surface* inSurface); Modified: trunk/include/gui/Label.h =================================================================== --- trunk/include/gui/Label.h 2008-04-17 17:17:14 UTC (rev 137) +++ trunk/include/gui/Label.h 2008-04-17 17:22:35 UTC (rev 138) @@ -17,7 +17,7 @@ void handleMotion(Uint32 x, Uint32 y); void handlePress(Uint32 x, Uint32 y); void handleRelease(Uint32 x, Uint32 y); - void setText(char* newText); + void setText(const char* newText); // inline char* getText() { return text; } @@ -27,7 +27,7 @@ inline void setTransparent(bool i) { transparent = i; } inline void setJustification(int i) { justification = i; } private: - char **splitLines(char* text, int delim); + char **splitLines(const char* text, int delim); char **text; int nLines; Modified: trunk/src/Game.cpp =================================================================== --- trunk/src/Game.cpp 2008-04-17 17:17:14 UTC (rev 137) +++ trunk/src/Game.cpp 2008-04-17 17:22:35 UTC (rev 138) @@ -3761,7 +3761,7 @@ { - char *finishMessage[] = { "You Have Completed Your Mission.", "You Have Failed Your Mission." }, + const char *finishMessage[] = { "You Have Completed Your Mission.", "You Have Failed Your Mission." }, *pausedMessage = "Paused", Modified: trunk/src/MapGenerator.cpp =================================================================== --- trunk/src/MapGenerator.cpp 2008-04-17 17:17:14 UTC (rev 137) +++ trunk/src/MapGenerator.cpp 2008-04-17 17:22:35 UTC (rev 138) @@ -608,7 +608,7 @@ smooth_terrain(); } -int readMapPlayerNumbers(char* filename, int numbers[MAX_PLAYERS]) +int readMapPlayerNumbers(const char* filename, int numbers[MAX_PLAYERS]) { int maxPlayers = NONE; FILE *file = fopen(filename, "rb"); @@ -636,7 +636,7 @@ return maxPlayers; } -int readMapMaxPlayers(char* filename) +int readMapMaxPlayers(const char* filename) { int maxPlayers = 0; FILE *file = fopen(filename, "rb"); @@ -1156,7 +1156,7 @@ return ok; } -bool loadMap(char* mapName) +bool loadMap(const char* mapName) { bool ok = false; FILE *mapFile = fopen(mapName, "rb"); Modified: trunk/src/Mentat.cpp =================================================================== --- trunk/src/Mentat.cpp 2008-04-17 17:17:14 UTC (rev 137) +++ trunk/src/Mentat.cpp 2008-04-17 17:22:35 UTC (rev 138) @@ -19,7 +19,7 @@ -char *mentatFileNames[Mentat_Unknown];//for the mentat character +const char *mentatFileNames[Mentat_Unknown];//for the mentat character @@ -29,7 +29,7 @@ -char *mentatDescriptionsAtreides[Mentat_Entry_Unknown];//for the mentat texts +const char *mentatDescriptionsAtreides[Mentat_Entry_Unknown];//for the mentat texts //char *mentatDescriptionsOrdos[Mentat_Entry_Unknown];//for the mentat texts @@ -41,7 +41,7 @@ int levelpics[22]; -char *levelBriefingText[22]; +const char *levelBriefingText[22]; @@ -925,7 +925,7 @@ -void Mentat::LoadMentatEntry(int entry, int frames, char *basePath, char *text) +void Mentat::LoadMentatEntry(int entry, int frames, const char *basePath, const char *text) { @@ -993,7 +993,7 @@ -char *Mentat::getFramePath(char *basePath, int frame) +const char *Mentat::getFramePath(const char *basePath, int frame) { @@ -1448,7 +1448,7 @@ -SDL_Surface *Mentat::loadImageFromZip(ZZIP_DIR *zzipdir, char *path) +SDL_Surface *Mentat::loadImageFromZip(ZZIP_DIR *zzipdir, const char *path) { Modified: trunk/src/MentatClass.cpp =================================================================== --- trunk/src/MentatClass.cpp 2008-04-17 17:17:14 UTC (rev 137) +++ trunk/src/MentatClass.cpp 2008-04-17 17:22:35 UTC (rev 138) @@ -925,7 +925,7 @@ -void MentatClass::LoadMentatEntry(int entry, int frames, char *basePath, char *text) +void MentatClass::LoadMentatEntry(int entry, int frames, const char *basePath, const char *text) { @@ -993,7 +993,7 @@ -char *MentatClass::getFramePath(char *basePath, int frame) +const char *MentatClass::getFramePath(const char *basePath, int frame) { @@ -1448,7 +1448,7 @@ -SDL_Surface *MentatClass::loadImageFromZip(ZZIP_DIR *zzipdir, char *path) +SDL_Surface *MentatClass::loadImageFromZip(ZZIP_DIR *zzipdir, const char *path) { Modified: trunk/src/Menu.cpp =================================================================== --- trunk/src/Menu.cpp 2008-04-17 17:17:14 UTC (rev 137) +++ trunk/src/Menu.cpp 2008-04-17 17:22:35 UTC (rev 138) @@ -66,7 +66,7 @@ } -char* colourName[7] = +const char* colourName[7] = { "Blue", "Green", Modified: trunk/src/editor.cpp =================================================================== --- trunk/src/editor.cpp 2008-04-17 17:17:14 UTC (rev 137) +++ trunk/src/editor.cpp 2008-04-17 17:22:35 UTC (rev 138) @@ -134,7 +134,7 @@ if (selectedRocks<1) selectedRocks = 1; } -void saveMap(char* filename) +void saveMap(const char* filename) { bool found[MAX_PLAYERS]; char temp[256]; Modified: trunk/src/gui/Button.cpp =================================================================== --- trunk/src/gui/Button.cpp 2008-04-17 17:17:14 UTC (rev 137) +++ trunk/src/gui/Button.cpp 2008-04-17 17:22:35 UTC (rev 138) @@ -391,7 +391,7 @@ callBackCancelData = newData; } -void Button::setHelpText(char* newText) +void Button::setHelpText(const char* newText) { strncpy(helpText, newText, MAX_LINE); @@ -426,7 +426,7 @@ pressedSurfaceSrc = *src; } -void Button::setText(char* newText) +void Button::setText(const char* newText) { strncpy(text, newText, MAX_LINE); @@ -453,7 +453,7 @@ focusedWidget = NULL; } -bool Button::textEquals(char* checkText) +bool Button::textEquals(const char* checkText) { return (strcmp(checkText, text) == 0); } Modified: trunk/src/gui/Entry.cpp =================================================================== --- trunk/src/gui/Entry.cpp 2008-04-17 17:17:14 UTC (rev 137) +++ trunk/src/gui/Entry.cpp 2008-04-17 17:22:35 UTC (rev 138) @@ -137,13 +137,13 @@ editable = truth; } -void Entry::setText(char *newText) +void Entry::setText(const char *newText) { strncpy(text, newText, MAX_NAMELENGTH); setFocused(false); } -bool Entry::textEquals(char* checkText) +bool Entry::textEquals(const char* checkText) { return (strcmp(checkText, text) == 0); } Modified: trunk/src/gui/Graphics.cpp =================================================================== --- trunk/src/gui/Graphics.cpp 2008-04-17 17:17:14 UTC (rev 137) +++ trunk/src/gui/Graphics.cpp 2008-04-17 17:22:35 UTC (rev 138) @@ -208,7 +208,7 @@ } -void showMessage(char* newMessage) +void showMessage(const char* newMessage) { //FIXME:Why should it be here?? Modified: trunk/src/gui/Label.cpp =================================================================== --- trunk/src/gui/Label.cpp 2008-04-17 17:17:14 UTC (rev 137) +++ trunk/src/gui/Label.cpp 2008-04-17 17:22:35 UTC (rev 138) @@ -99,7 +99,7 @@ } -void Label::setText(char *newText) +void Label::setText(const char *newText) { //strncpy(text, newText, MAX_LINE); @@ -133,7 +133,7 @@ } } -char **Label::splitLines(char *text, int delim) +char **Label::splitLines(const char *text, int delim) { char **newText; char *lastPtr; @@ -141,7 +141,7 @@ int nTokens = 0; int len = 0; - lastPtr = text; + lastPtr = (char*)text; while( (newPtr = strchr(lastPtr, delim)) ) { @@ -150,7 +150,7 @@ } newText = (char **)malloc(sizeof(char *) * nTokens); - lastPtr = text; + lastPtr = (char*)text; nTokens = 0; while( (newPtr = strchr(lastPtr, delim)) ) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dv...@us...> - 2008-04-17 16:47:57
|
Revision: 136 http://dunelegacy.svn.sourceforge.net/dunelegacy/?rev=136&view=rev Author: dvalin Date: 2008-04-17 09:47:18 -0700 (Thu, 17 Apr 2008) Log Message: ----------- convert to unix style eol Modified Paths: -------------- trunk/include/Mentat.h Modified: trunk/include/Mentat.h =================================================================== --- trunk/include/Mentat.h 2008-04-17 16:45:05 UTC (rev 135) +++ trunk/include/Mentat.h 2008-04-17 16:47:18 UTC (rev 136) @@ -1,271 +1,271 @@ -#ifndef DUNE_MENTATCLASS_H -#define DUNE_MENTATCLASS_H - -#include "SDL_rwops_zzip.h" -#include "zzip/zzip.h" -#include "BuildItemClass.h" +#ifndef DUNE_MENTATCLASS_H +#define DUNE_MENTATCLASS_H + +#include "SDL_rwops_zzip.h" +#include "zzip/zzip.h" +#include "BuildItemClass.h" #include "gui.h" -#include "singleton.h" - -typedef enum -{ - Mentat_Atreides, - Mentat_Ordos, - Mentat_Harkonnen, - Mentat_Atreides_Eyes1, - Mentat_Atreides_Eyes2, - Mentat_Atreides_Eyes3, - Mentat_Atreides_Eyes4, - Mentat_Atreides_Eyes5, - Mentat_Atreides_Mouth1, - Mentat_Atreides_Mouth2, - Mentat_Atreides_Mouth3, - Mentat_Atreides_Mouth4, - Mentat_Atreides_Mouth5, - Mentat_Atreides_Shoulder, - Mentat_Ordos_Eyes1, - Mentat_Ordos_Eyes2, - Mentat_Ordos_Eyes3, - Mentat_Ordos_Eyes4, - Mentat_Ordos_Eyes5, - Mentat_Ordos_Mouth1, - Mentat_Ordos_Mouth2, - Mentat_Ordos_Mouth3, - Mentat_Ordos_Mouth4, - Mentat_Ordos_Mouth5, - Mentat_Ordos_Shoulder, - Mentat_Harkonnen_Eyes1, - Mentat_Harkonnen_Eyes2, - Mentat_Harkonnen_Eyes3, - Mentat_Harkonnen_Eyes4, - Mentat_Harkonnen_Eyes5, - Mentat_Harkonnen_Mouth1, - Mentat_Harkonnen_Mouth2, - Mentat_Harkonnen_Mouth3, - Mentat_Harkonnen_Mouth4, - Mentat_Harkonnen_Mouth5, - Mentat_Harkonnen_Shoulder, - //Ordos Ring - //Atreides Book - Mentat_Unknown -} MENTAT_DATA; - -#define FRAMES_CONCRETE_SLAB 1 -#define FRAMES_BARRACKS 3 -#define FRAMES_CARRYALL 2 -#define FRAMES_CONST_YARD 1 -#define FRAMES_ATRE_WORLD 30 -#define FRAMES_HARK_WORLD 30 -#define FRAMES_ORDOS_WORLD 30 -#define FRAMES_FREMEN 2 -#define FRAMES_FRIGATE 1 -#define FRAMES_DEATHHAND 16 -#define FRAMES_DEVASTATOR 1 -#define FRAMES_HARVESTER 13 -#define FRAMES_RADAR 10 -#define FRAMES_HIGHTECH 2 -#define FRAMES_SEIGETANK 1 -#define FRAMES_HEAVYFACT 7 -#define FRAMES_HEAVYINF 1 -#define FRAMES_INFANTRY 1 -#define FRAMES_IX 1 -#define FRAMES_LIGHTFACT 14 -#define FRAMES_COMBATTANK 1 -#define FRAMES_MCV 1 -#define FRAMES_DEVIATOR 1 -#define FRAMES_ORNI 1 -#define FRAMES_RAIDER 1 -#define FRAMES_PALACE 17 -#define FRAMES_REFINERY 6 -#define FRAMES_REPAIRBAY 1 -#define FRAMES_ROCKETTANK 1 -#define FRAMES_ROCKETTURRET 1 -#define FRAMES_SABOTEUR 1 -#define FRAMES_SARDAUKAR 10 -#define FRAMES_SLAB 1 -#define FRAMES_SONICTANK 1 -#define FRAMES_STARPORT 25 -#define FRAMES_SILO 4 -#define FRAMES_TRIKE 1 -#define FRAMES_TURRET 1 -#define FRAMES_WALL 1 -#define FRAMES_WINDTRAP 12 -#define FRAMES_WOR 8 -#define FRAMES_WORM 1 -#define FRAMES_QUAD 1 - -typedef enum -{ - Mentat_Concrete_Slab, - Mentat_Barracks, - Mentat_Carryall, - Mentat_Construction_Yard, - Mentat_Atreides_World, - Mentat_Harkonnen_World, - Mentat_Ordos_World, - Mentat_Fremen, - Mentat_Frigate, - Mentat_Deathhand, - Mentat_Devastator, - Mentat_Harvester, - Mentat_Radar, - Mentat_HighTech, - Mentat_SeigeTank, - Mentat_HeavyFactory, - Mentat_HeavyInfantry, - Mentat_Infantry, - Mentat_IX, - Mentat_LightFactory, - Mentat_CombatTank, - Mentat_MCV, - Mentat_Deviator, - Mentat_Ornithopter, - Mentat_Raider, - Mentat_Palace, - Mentat_Quad, - Mentat_Refinery, - Mentat_RepairBay, - Mentat_RocketTank, - Mentat_RocketTurret, - Mentat_Saboteur, - Mentat_Sardaukar, - Mentat_Slab, - Mentat_SonicTank, - Mentat_Starport, - Mentat_Silo, - Mentat_Trike, - Mentat_Turret, - Mentat_Wall, - Mentat_Windtrap, - Mentat_WOR, - Mentat_Worm, - Mentat_Entry_Unknown -} MENTAT_ENTRIES; - -typedef struct Mentat_Entry -{ - SDL_Surface *staticpic; - SDL_Surface **pic; - char *text; - char *fullText[512];//needed? - char *basePath; - - int frames; - int curFrame; - - int picID; - bool loaded; -} MentatEntry; - - - -class Mentat:public Singleton<Mentat> -{ - friend class Singleton<Mentat>; -public: - Mentat(); - ~Mentat(); - void showMentat(); - bool doExit(); - void draw(); - void handlePress(int x, int y); - void handleCancelPress(int x, int y); - void handleRelease(int x, int y); - void handleCancelRelease(int x, int y); - void LoadData(); - void LoadMentatEntry(int entry, int frames, char *basePath, char *text); - void UnLoadMentatEntry(int entry); - void setMentatView(int entry); - char *getFramePath(char *basePath, int frame); - void createList(); - void checkMinMaxSelection(); - - void doBriefing(int level); - int doHouseChoice(); - bool doHouseInfo(int h); - - void makeTextSurface(int num); - - static void handleUp(void *val); - static void handleDown(void *val); - static void listButtonCallBack(void *val); - - static void yesCallback(void *val); - static void noCallback(void *val); - static void houseChoiceCallbackA(void *val); - static void houseChoiceCallbackO(void *val); - static void houseChoiceCallbackH(void *val); - inline void setHouseChoiceExitValue(int b) { houseChoiceExitValue = b; } - inline void setHouseChoiceValue(int b) { houseChoiceValue = b; } - - void handleInput(); - static void briefingButtonCallback(void *val); - inline void setBriefingRunning(bool b) { briefingRunning = b; } - - - void doUp(); - void doDown(); - - void updateTimers(); - void setHouse(int h); - - void UnloadTemporaryData(); - - SDL_Surface *loadImageFromZip(ZZIP_DIR* zzipdir, char *path); - -private: - Window *mentatWindow; - int house; - int currentViewID; - int frameTimer, mouthTimer, eyesTimer; - int eyesFrame, mouthFrame; - int talkLength; - int minSelection; - int maxSelection; - SDL_Surface *mentatSurface; - SDL_Surface *mentatExitSurf; +#include "singleton.h" + +typedef enum +{ + Mentat_Atreides, + Mentat_Ordos, + Mentat_Harkonnen, + Mentat_Atreides_Eyes1, + Mentat_Atreides_Eyes2, + Mentat_Atreides_Eyes3, + Mentat_Atreides_Eyes4, + Mentat_Atreides_Eyes5, + Mentat_Atreides_Mouth1, + Mentat_Atreides_Mouth2, + Mentat_Atreides_Mouth3, + Mentat_Atreides_Mouth4, + Mentat_Atreides_Mouth5, + Mentat_Atreides_Shoulder, + Mentat_Ordos_Eyes1, + Mentat_Ordos_Eyes2, + Mentat_Ordos_Eyes3, + Mentat_Ordos_Eyes4, + Mentat_Ordos_Eyes5, + Mentat_Ordos_Mouth1, + Mentat_Ordos_Mouth2, + Mentat_Ordos_Mouth3, + Mentat_Ordos_Mouth4, + Mentat_Ordos_Mouth5, + Mentat_Ordos_Shoulder, + Mentat_Harkonnen_Eyes1, + Mentat_Harkonnen_Eyes2, + Mentat_Harkonnen_Eyes3, + Mentat_Harkonnen_Eyes4, + Mentat_Harkonnen_Eyes5, + Mentat_Harkonnen_Mouth1, + Mentat_Harkonnen_Mouth2, + Mentat_Harkonnen_Mouth3, + Mentat_Harkonnen_Mouth4, + Mentat_Harkonnen_Mouth5, + Mentat_Harkonnen_Shoulder, + //Ordos Ring + //Atreides Book + Mentat_Unknown +} MENTAT_DATA; + +#define FRAMES_CONCRETE_SLAB 1 +#define FRAMES_BARRACKS 3 +#define FRAMES_CARRYALL 2 +#define FRAMES_CONST_YARD 1 +#define FRAMES_ATRE_WORLD 30 +#define FRAMES_HARK_WORLD 30 +#define FRAMES_ORDOS_WORLD 30 +#define FRAMES_FREMEN 2 +#define FRAMES_FRIGATE 1 +#define FRAMES_DEATHHAND 16 +#define FRAMES_DEVASTATOR 1 +#define FRAMES_HARVESTER 13 +#define FRAMES_RADAR 10 +#define FRAMES_HIGHTECH 2 +#define FRAMES_SEIGETANK 1 +#define FRAMES_HEAVYFACT 7 +#define FRAMES_HEAVYINF 1 +#define FRAMES_INFANTRY 1 +#define FRAMES_IX 1 +#define FRAMES_LIGHTFACT 14 +#define FRAMES_COMBATTANK 1 +#define FRAMES_MCV 1 +#define FRAMES_DEVIATOR 1 +#define FRAMES_ORNI 1 +#define FRAMES_RAIDER 1 +#define FRAMES_PALACE 17 +#define FRAMES_REFINERY 6 +#define FRAMES_REPAIRBAY 1 +#define FRAMES_ROCKETTANK 1 +#define FRAMES_ROCKETTURRET 1 +#define FRAMES_SABOTEUR 1 +#define FRAMES_SARDAUKAR 10 +#define FRAMES_SLAB 1 +#define FRAMES_SONICTANK 1 +#define FRAMES_STARPORT 25 +#define FRAMES_SILO 4 +#define FRAMES_TRIKE 1 +#define FRAMES_TURRET 1 +#define FRAMES_WALL 1 +#define FRAMES_WINDTRAP 12 +#define FRAMES_WOR 8 +#define FRAMES_WORM 1 +#define FRAMES_QUAD 1 + +typedef enum +{ + Mentat_Concrete_Slab, + Mentat_Barracks, + Mentat_Carryall, + Mentat_Construction_Yard, + Mentat_Atreides_World, + Mentat_Harkonnen_World, + Mentat_Ordos_World, + Mentat_Fremen, + Mentat_Frigate, + Mentat_Deathhand, + Mentat_Devastator, + Mentat_Harvester, + Mentat_Radar, + Mentat_HighTech, + Mentat_SeigeTank, + Mentat_HeavyFactory, + Mentat_HeavyInfantry, + Mentat_Infantry, + Mentat_IX, + Mentat_LightFactory, + Mentat_CombatTank, + Mentat_MCV, + Mentat_Deviator, + Mentat_Ornithopter, + Mentat_Raider, + Mentat_Palace, + Mentat_Quad, + Mentat_Refinery, + Mentat_RepairBay, + Mentat_RocketTank, + Mentat_RocketTurret, + Mentat_Saboteur, + Mentat_Sardaukar, + Mentat_Slab, + Mentat_SonicTank, + Mentat_Starport, + Mentat_Silo, + Mentat_Trike, + Mentat_Turret, + Mentat_Wall, + Mentat_Windtrap, + Mentat_WOR, + Mentat_Worm, + Mentat_Entry_Unknown +} MENTAT_ENTRIES; + +typedef struct Mentat_Entry +{ + SDL_Surface *staticpic; + SDL_Surface **pic; + char *text; + char *fullText[512];//needed? + char *basePath; + + int frames; + int curFrame; + + int picID; + bool loaded; +} MentatEntry; + + + +class Mentat:public Singleton<Mentat> +{ + friend class Singleton<Mentat>; +public: + Mentat(); + ~Mentat(); + void showMentat(); + bool doExit(); + void draw(); + void handlePress(int x, int y); + void handleCancelPress(int x, int y); + void handleRelease(int x, int y); + void handleCancelRelease(int x, int y); + void LoadData(); + void LoadMentatEntry(int entry, int frames, char *basePath, char *text); + void UnLoadMentatEntry(int entry); + void setMentatView(int entry); + char *getFramePath(char *basePath, int frame); + void createList(); + void checkMinMaxSelection(); + + void doBriefing(int level); + int doHouseChoice(); + bool doHouseInfo(int h); + + void makeTextSurface(int num); + + static void handleUp(void *val); + static void handleDown(void *val); + static void listButtonCallBack(void *val); + + static void yesCallback(void *val); + static void noCallback(void *val); + static void houseChoiceCallbackA(void *val); + static void houseChoiceCallbackO(void *val); + static void houseChoiceCallbackH(void *val); + inline void setHouseChoiceExitValue(int b) { houseChoiceExitValue = b; } + inline void setHouseChoiceValue(int b) { houseChoiceValue = b; } + + void handleInput(); + static void briefingButtonCallback(void *val); + inline void setBriefingRunning(bool b) { briefingRunning = b; } + + + void doUp(); + void doDown(); + + void updateTimers(); + void setHouse(int h); + + void UnloadTemporaryData(); + + SDL_Surface *loadImageFromZip(ZZIP_DIR* zzipdir, char *path); + +private: + Window *mentatWindow; + int house; + int currentViewID; + int frameTimer, mouthTimer, eyesTimer; + int eyesFrame, mouthFrame; + int talkLength; + int minSelection; + int maxSelection; + SDL_Surface *mentatSurface; + SDL_Surface *mentatExitSurf; SDL_Surface *mentatExitSurfPressed; - SDL_Surface *mentatProceedSurf; + SDL_Surface *mentatProceedSurf; SDL_Surface *mentatProceedSurfPressed; - - //SDL_Surface *textSurface; - SDL_Surface *shoulderSurface; - - SDL_Surface *eyesFrames[5]; - SDL_Surface *mouthFrames[5]; - SDL_Rect mentatPos, graphicPos, textPos, mouthPos, eyesPos, shoulderPos; - HBox mentatButtons; - VBox listBox; - Button buttonExit, buttonOK, listBt1, listBt2, listBt3, listBt4, listBt5, listBt6, listUp, listDown; - - BUILD_ITEM_DATA data1, data2, data3, data4, data5, data6;//holds a void * and a number, perfect for what we need - - ListIterator *selectionList; - - int loadedBefore; - - Mentat_Entry levelEntry; - bool inBriefing; - bool briefingRunning; - - bool inHouseChoice; - bool inInfoScreen; - - int houseChoiceExitValue; - int houseChoiceValue; - - Button houseAtre, houseOrdos, houseHark; - HBox houseButtons; - Window *houseChoiceWindow; - SDL_Surface *heraldSurf; - - Button yesButton, noButton;//buttons for yes and no - HBox yesNoButtons; - Window *houseInfoWindow; - Label textLabel; - - char *zipPath; -}; - -#endif // DUNE_MENTATCLASS_H - + + //SDL_Surface *textSurface; + SDL_Surface *shoulderSurface; + + SDL_Surface *eyesFrames[5]; + SDL_Surface *mouthFrames[5]; + SDL_Rect mentatPos, graphicPos, textPos, mouthPos, eyesPos, shoulderPos; + HBox mentatButtons; + VBox listBox; + Button buttonExit, buttonOK, listBt1, listBt2, listBt3, listBt4, listBt5, listBt6, listUp, listDown; + + BUILD_ITEM_DATA data1, data2, data3, data4, data5, data6;//holds a void * and a number, perfect for what we need + + ListIterator *selectionList; + + int loadedBefore; + + Mentat_Entry levelEntry; + bool inBriefing; + bool briefingRunning; + + bool inHouseChoice; + bool inInfoScreen; + + int houseChoiceExitValue; + int houseChoiceValue; + + Button houseAtre, houseOrdos, houseHark; + HBox houseButtons; + Window *houseChoiceWindow; + SDL_Surface *heraldSurf; + + Button yesButton, noButton;//buttons for yes and no + HBox yesNoButtons; + Window *houseInfoWindow; + Label textLabel; + + char *zipPath; +}; + +#endif // DUNE_MENTATCLASS_H + This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dv...@us...> - 2008-04-17 16:45:41
|
Revision: 135 http://dunelegacy.svn.sourceforge.net/dunelegacy/?rev=135&view=rev Author: dvalin Date: 2008-04-17 09:45:05 -0700 (Thu, 17 Apr 2008) Log Message: ----------- convert to unix style eol Modified Paths: -------------- trunk/include/Menu.h Modified: trunk/include/Menu.h =================================================================== --- trunk/include/Menu.h 2008-04-17 16:41:25 UTC (rev 134) +++ trunk/include/Menu.h 2008-04-17 16:45:05 UTC (rev 135) @@ -1,291 +1,291 @@ -#ifndef DUNE_MENU_H +#ifndef DUNE_MENU_H #define DUNE_MENU_H #include "SDL.h" -#include "gui.h" +#include "gui.h" #include "gui/Graphics.h" -#include "SDL_thread.h" -#include "SDL_net.h" - -int houseNameToNum(char* house); - -#define SCREEN_BPP 8 -#define VERSION "0.94.1" - - -SDL_Surface *screen; - - -Window *singleWindow; -Window *skirmishWindow; -Window *customWindow; -Window *mainWindow, *multiWindow; -Window loadGameWindow; - -Button loadCancelButton, gameLoadSpot[NUM_SAVEGAMES]; - -Button *single_buttonSkirmish; -Button *single_buttonCampaign; -Button *single_buttonCustom; -Button *single_buttonLoad; -Button *single_buttonCancel; -Button *single_buttonSkirmishStart; -Button *single_buttonSkirmishCancel; -Button *single_buttonSkirmishAtre; -Button *single_buttonSkirmishHark; -Button *single_buttonSkirmishOrdos; -Button *single_buttonSkirmishHerald; -Button *single_buttonMissionPlus; -Button *single_buttonMissionMinus; -Button *menu_mission; -Button *menu_difficulty; - -int selectedHouse; -int selectedMission = 1; - - -Label skirmishLabel; -Label customLabel; -Label multiLabel; - - -//int settings.campaignLevel; - - - -Button *main_buttonSinglePlayer, - - *main_buttonMultiPlayer, - - *main_buttonMapEditor, - - *main_buttonOptions, - - *main_buttonAbout, - - *main_buttonQuit, - - - - *single_buttonDifficulty, - - *single_buttonHouse, - - - -// single_buttonCampaign, - - *single_buttonRandomMap, - - *single_buttonSingleMap, - -// single_buttonCancel, - - - - custom_buttonName[MAX_PLAYERS], - - custom_buttonColour[MAX_PLAYERS], - - custom_buttonHouse[MAX_PLAYERS], - - custom_buttonTeam[MAX_PLAYERS], - - custom_buttonStart, - - custom_buttonCancel, - - - - multi_buttonCreate, - - multi_buttonJoin, - - multi_buttonCancel, - - - - multiServer_buttonName[MAX_PLAYERS], - - multiServer_buttonColour[MAX_PLAYERS], - - multiServer_buttonHouse[MAX_PLAYERS], - - multiServer_buttonTeam[MAX_PLAYERS], - - multiServer_buttonStart, - - multiServer_buttonKick, - - multiServer_buttonCancel, - - - - multiClient_buttonName[MAX_PLAYERS], - - multiClient_buttonColour[MAX_PLAYERS], - - multiClient_buttonHouse[MAX_PLAYERS], - - multiClient_buttonTeam[MAX_PLAYERS], - - multiClient_buttonCancel, - - multiClient_buttonMessage, - - - - options_buttonConcrete, - - options_buttonRes, - - options_buttonFullScreen, - - options_buttonDoubleBuffered, - - options_buttonOk, - - options_buttonCancel; - - - -Entry multi_address, - - options_name; - - - -HBox multi_hbox, - - custom_hbox, - - custom_clientHbox[MAX_PLAYERS], - - multiClient_hbox, - - multiClient_clientHbox[MAX_PLAYERS], - - multiServer_hbox, - - multiServer_clientHbox[MAX_PLAYERS], - - single_hbox, - - options_hbox; - -VBox main_vbox, - - custom_vbox, - - custom_vbox2, - - custom_vbox3, - - single_vbox, - - single_vbox2, - - multi_vbox, - - multi_vbox2, - - multiClient_vbox, - - multiClient_vbox2, - - multiClient_vbox3, - - multiServer_vbox, - - multiServer_vbox2, - - multiServer_vbox3, - - options_vbox; - -Widget *currentWidget, - *focusedWidget = NULL; - -Window about_window; - - - - - -bool gameCreated, - - createThreadValid, - - quiting, - - joinThreadValid, - - multi_buttonHit, - - multiGameStarting; - -bool inMainMenu; - - - -int backgroundOffsetX, - - backgroundOffsetY, - - - - multi_buttonRow, - - playersJoined; - - - -TCPsocket sockets[MAX_PLAYERS]; - -TCPsocket server; - -SDLNet_SocketSet socketSet; - - - -SDL_Thread *multiGame_thread = NULL; - -SDL_mutex *mutex_button = NULL, - - *mutex_currentWidget = NULL, - - *mutex_playersJoined = NULL; - - - -SDL_Surface *menu, - - *menuText; - - - -void setVideoMode(); - -void realign_buttons(); - - - -char* houseName[9] = - -{ - - "Atreides", - - "Ordos", - - "Harkonnen", - - "Sardaukar", - - "Fremen", - - "Mercenary" - -}; - -#endif // DUNE_MENU_H +#include "SDL_thread.h" +#include "SDL_net.h" + +int houseNameToNum(char* house); + +#define SCREEN_BPP 8 +#define VERSION "0.94.1" + + +SDL_Surface *screen; + + +Window *singleWindow; +Window *skirmishWindow; +Window *customWindow; +Window *mainWindow, *multiWindow; +Window loadGameWindow; + +Button loadCancelButton, gameLoadSpot[NUM_SAVEGAMES]; + +Button *single_buttonSkirmish; +Button *single_buttonCampaign; +Button *single_buttonCustom; +Button *single_buttonLoad; +Button *single_buttonCancel; +Button *single_buttonSkirmishStart; +Button *single_buttonSkirmishCancel; +Button *single_buttonSkirmishAtre; +Button *single_buttonSkirmishHark; +Button *single_buttonSkirmishOrdos; +Button *single_buttonSkirmishHerald; +Button *single_buttonMissionPlus; +Button *single_buttonMissionMinus; +Button *menu_mission; +Button *menu_difficulty; + +int selectedHouse; +int selectedMission = 1; + + +Label skirmishLabel; +Label customLabel; +Label multiLabel; + + +//int settings.campaignLevel; + + + +Button *main_buttonSinglePlayer, + + *main_buttonMultiPlayer, + + *main_buttonMapEditor, + + *main_buttonOptions, + + *main_buttonAbout, + + *main_buttonQuit, + + + + *single_buttonDifficulty, + + *single_buttonHouse, + + + +// single_buttonCampaign, + + *single_buttonRandomMap, + + *single_buttonSingleMap, + +// single_buttonCancel, + + + + custom_buttonName[MAX_PLAYERS], + + custom_buttonColour[MAX_PLAYERS], + + custom_buttonHouse[MAX_PLAYERS], + + custom_buttonTeam[MAX_PLAYERS], + + custom_buttonStart, + + custom_buttonCancel, + + + + multi_buttonCreate, + + multi_buttonJoin, + + multi_buttonCancel, + + + + multiServer_buttonName[MAX_PLAYERS], + + multiServer_buttonColour[MAX_PLAYERS], + + multiServer_buttonHouse[MAX_PLAYERS], + + multiServer_buttonTeam[MAX_PLAYERS], + + multiServer_buttonStart, + + multiServer_buttonKick, + + multiServer_buttonCancel, + + + + multiClient_buttonName[MAX_PLAYERS], + + multiClient_buttonColour[MAX_PLAYERS], + + multiClient_buttonHouse[MAX_PLAYERS], + + multiClient_buttonTeam[MAX_PLAYERS], + + multiClient_buttonCancel, + + multiClient_buttonMessage, + + + + options_buttonConcrete, + + options_buttonRes, + + options_buttonFullScreen, + + options_buttonDoubleBuffered, + + options_buttonOk, + + options_buttonCancel; + + + +Entry multi_address, + + options_name; + + + +HBox multi_hbox, + + custom_hbox, + + custom_clientHbox[MAX_PLAYERS], + + multiClient_hbox, + + multiClient_clientHbox[MAX_PLAYERS], + + multiServer_hbox, + + multiServer_clientHbox[MAX_PLAYERS], + + single_hbox, + + options_hbox; + +VBox main_vbox, + + custom_vbox, + + custom_vbox2, + + custom_vbox3, + + single_vbox, + + single_vbox2, + + multi_vbox, + + multi_vbox2, + + multiClient_vbox, + + multiClient_vbox2, + + multiClient_vbox3, + + multiServer_vbox, + + multiServer_vbox2, + + multiServer_vbox3, + + options_vbox; + +Widget *currentWidget, + *focusedWidget = NULL; + +Window about_window; + + + + + +bool gameCreated, + + createThreadValid, + + quiting, + + joinThreadValid, + + multi_buttonHit, + + multiGameStarting; + +bool inMainMenu; + + + +int backgroundOffsetX, + + backgroundOffsetY, + + + + multi_buttonRow, + + playersJoined; + + + +TCPsocket sockets[MAX_PLAYERS]; + +TCPsocket server; + +SDLNet_SocketSet socketSet; + + + +SDL_Thread *multiGame_thread = NULL; + +SDL_mutex *mutex_button = NULL, + + *mutex_currentWidget = NULL, + + *mutex_playersJoined = NULL; + + + +SDL_Surface *menu, + + *menuText; + + + +void setVideoMode(); + +void realign_buttons(); + + + +char* houseName[9] = + +{ + + "Atreides", + + "Ordos", + + "Harkonnen", + + "Sardaukar", + + "Fremen", + + "Mercenary" + +}; + +#endif // DUNE_MENU_H This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dv...@us...> - 2008-04-17 16:41:35
|
Revision: 134 http://dunelegacy.svn.sourceforge.net/dunelegacy/?rev=134&view=rev Author: dvalin Date: 2008-04-17 09:41:25 -0700 (Thu, 17 Apr 2008) Log Message: ----------- convert to unix style eol Modified Paths: -------------- trunk/include/MentatClass.h Modified: trunk/include/MentatClass.h =================================================================== --- trunk/include/MentatClass.h 2008-04-17 16:27:35 UTC (rev 133) +++ trunk/include/MentatClass.h 2008-04-17 16:41:25 UTC (rev 134) @@ -1,270 +1,270 @@ -#ifndef DUNE_MENTATCLASS_H -#define DUNE_MENTATCLASS_H - -#include "SDL_rwops_zzip.h" -#include "zzip/zzip.h" -#include "BuildItemClass.h" -#include "gui.h" - -typedef enum -{ - Mentat_Atreides, - Mentat_Ordos, - Mentat_Harkonnen, - Mentat_Atreides_Eyes1, - Mentat_Atreides_Eyes2, - Mentat_Atreides_Eyes3, - Mentat_Atreides_Eyes4, - Mentat_Atreides_Eyes5, - Mentat_Atreides_Mouth1, - Mentat_Atreides_Mouth2, - Mentat_Atreides_Mouth3, - Mentat_Atreides_Mouth4, - Mentat_Atreides_Mouth5, - Mentat_Atreides_Shoulder, - Mentat_Ordos_Eyes1, - Mentat_Ordos_Eyes2, - Mentat_Ordos_Eyes3, - Mentat_Ordos_Eyes4, - Mentat_Ordos_Eyes5, - Mentat_Ordos_Mouth1, - Mentat_Ordos_Mouth2, - Mentat_Ordos_Mouth3, - Mentat_Ordos_Mouth4, - Mentat_Ordos_Mouth5, - Mentat_Ordos_Shoulder, - Mentat_Harkonnen_Eyes1, - Mentat_Harkonnen_Eyes2, - Mentat_Harkonnen_Eyes3, - Mentat_Harkonnen_Eyes4, - Mentat_Harkonnen_Eyes5, - Mentat_Harkonnen_Mouth1, - Mentat_Harkonnen_Mouth2, - Mentat_Harkonnen_Mouth3, - Mentat_Harkonnen_Mouth4, - Mentat_Harkonnen_Mouth5, - Mentat_Harkonnen_Shoulder, - //Ordos Ring - //Atreides Book - Mentat_Unknown -} MENTAT_DATA; - -#define FRAMES_CONCRETE_SLAB 1 -#define FRAMES_BARRACKS 3 -#define FRAMES_CARRYALL 2 -#define FRAMES_CONST_YARD 1 -#define FRAMES_ATRE_WORLD 30 -#define FRAMES_HARK_WORLD 30 -#define FRAMES_ORDOS_WORLD 30 -#define FRAMES_FREMEN 2 -#define FRAMES_FRIGATE 1 -#define FRAMES_DEATHHAND 16 -#define FRAMES_DEVASTATOR 1 -#define FRAMES_HARVESTER 13 -#define FRAMES_RADAR 10 -#define FRAMES_HIGHTECH 2 -#define FRAMES_SEIGETANK 1 -#define FRAMES_HEAVYFACT 7 -#define FRAMES_HEAVYINF 1 -#define FRAMES_INFANTRY 1 -#define FRAMES_IX 1 -#define FRAMES_LIGHTFACT 14 -#define FRAMES_COMBATTANK 1 -#define FRAMES_MCV 1 -#define FRAMES_DEVIATOR 1 -#define FRAMES_ORNI 1 -#define FRAMES_RAIDER 1 -#define FRAMES_PALACE 17 -#define FRAMES_REFINERY 6 -#define FRAMES_REPAIRBAY 1 -#define FRAMES_ROCKETTANK 1 -#define FRAMES_ROCKETTURRET 1 -#define FRAMES_SABOTEUR 1 -#define FRAMES_SARDAUKAR 10 -#define FRAMES_SLAB 1 -#define FRAMES_SONICTANK 1 -#define FRAMES_STARPORT 25 -#define FRAMES_SILO 4 -#define FRAMES_TRIKE 1 -#define FRAMES_TURRET 1 -#define FRAMES_WALL 1 -#define FRAMES_WINDTRAP 12 -#define FRAMES_WOR 8 -#define FRAMES_WORM 1 -#define FRAMES_QUAD 1 - -typedef enum -{ - Mentat_Concrete_Slab, - Mentat_Barracks, - Mentat_Carryall, - Mentat_Construction_Yard, - Mentat_Atreides_World, - Mentat_Harkonnen_World, - Mentat_Ordos_World, - Mentat_Fremen, - Mentat_Frigate, - Mentat_Deathhand, - Mentat_Devastator, - Mentat_Harvester, - Mentat_Radar, - Mentat_HighTech, - Mentat_SeigeTank, - Mentat_HeavyFactory, - Mentat_HeavyInfantry, - Mentat_Infantry, - Mentat_IX, - Mentat_LightFactory, - Mentat_CombatTank, - Mentat_MCV, - Mentat_Deviator, - Mentat_Ornithopter, - Mentat_Raider, - Mentat_Palace, - Mentat_Quad, - Mentat_Refinery, - Mentat_RepairBay, - Mentat_RocketTank, - Mentat_RocketTurret, - Mentat_Saboteur, - Mentat_Sardaukar, - Mentat_Slab, - Mentat_SonicTank, - Mentat_Starport, - Mentat_Silo, - Mentat_Trike, - Mentat_Turret, - Mentat_Wall, - Mentat_Windtrap, - Mentat_WOR, - Mentat_Worm, - Mentat_Entry_Unknown -} MENTAT_ENTRIES; - -typedef struct Mentat_Entry -{ - SDL_Surface *staticpic; - SDL_Surface **pic; - char *text; - char *fullText[512];//needed? - char *basePath; - - int frames; - int curFrame; - - int picID; - bool loaded; -} MentatEntry; - - - -class MentatClass -{ - -public: - MentatClass(); - ~MentatClass(); - void showMentat(); - bool doExit(); - void draw(); - void handlePress(int x, int y); - void handleCancelPress(int x, int y); - void handleRelease(int x, int y); - void handleCancelRelease(int x, int y); - void LoadData(); - void LoadMentatEntry(int entry, int frames, char *basePath, char *text); - void UnLoadMentatEntry(int entry); - void setMentatView(int entry); - char *getFramePath(char *basePath, int frame); - void createList(); - void checkMinMaxSelection(); - - void doBriefing(int level); - int doHouseChoice(); - bool doHouseInfo(int h); - - void makeTextSurface(int num); - - static void handleUp(void *val); - static void handleDown(void *val); - static void listButtonCallBack(void *val); - - static void yesCallback(void *val); - static void noCallback(void *val); - static void houseChoiceCallbackA(void *val); - static void houseChoiceCallbackO(void *val); - static void houseChoiceCallbackH(void *val); - inline void setHouseChoiceExitValue(int b) { houseChoiceExitValue = b; } - inline void setHouseChoiceValue(int b) { houseChoiceValue = b; } - - void handleInput(); - static void briefingButtonCallback(void *val); - inline void setBriefingRunning(bool b) { briefingRunning = b; } - - - void doUp(); - void doDown(); - - void updateTimers(); - void setHouse(int h); - - void UnloadTemporaryData(); - - SDL_Surface *loadImageFromZip(ZZIP_DIR* zzipdir, char *path); - -private: - Window *mentatWindow; - int house; - int currentViewID; - int frameTimer, mouthTimer, eyesTimer; - int eyesFrame, mouthFrame; - int talkLength; - int minSelection; - int maxSelection; - SDL_Surface *mentatSurface; - SDL_Surface *mentatExitSurf; +#ifndef DUNE_MENTATCLASS_H +#define DUNE_MENTATCLASS_H + +#include "SDL_rwops_zzip.h" +#include "zzip/zzip.h" +#include "BuildItemClass.h" +#include "gui.h" + +typedef enum +{ + Mentat_Atreides, + Mentat_Ordos, + Mentat_Harkonnen, + Mentat_Atreides_Eyes1, + Mentat_Atreides_Eyes2, + Mentat_Atreides_Eyes3, + Mentat_Atreides_Eyes4, + Mentat_Atreides_Eyes5, + Mentat_Atreides_Mouth1, + Mentat_Atreides_Mouth2, + Mentat_Atreides_Mouth3, + Mentat_Atreides_Mouth4, + Mentat_Atreides_Mouth5, + Mentat_Atreides_Shoulder, + Mentat_Ordos_Eyes1, + Mentat_Ordos_Eyes2, + Mentat_Ordos_Eyes3, + Mentat_Ordos_Eyes4, + Mentat_Ordos_Eyes5, + Mentat_Ordos_Mouth1, + Mentat_Ordos_Mouth2, + Mentat_Ordos_Mouth3, + Mentat_Ordos_Mouth4, + Mentat_Ordos_Mouth5, + Mentat_Ordos_Shoulder, + Mentat_Harkonnen_Eyes1, + Mentat_Harkonnen_Eyes2, + Mentat_Harkonnen_Eyes3, + Mentat_Harkonnen_Eyes4, + Mentat_Harkonnen_Eyes5, + Mentat_Harkonnen_Mouth1, + Mentat_Harkonnen_Mouth2, + Mentat_Harkonnen_Mouth3, + Mentat_Harkonnen_Mouth4, + Mentat_Harkonnen_Mouth5, + Mentat_Harkonnen_Shoulder, + //Ordos Ring + //Atreides Book + Mentat_Unknown +} MENTAT_DATA; + +#define FRAMES_CONCRETE_SLAB 1 +#define FRAMES_BARRACKS 3 +#define FRAMES_CARRYALL 2 +#define FRAMES_CONST_YARD 1 +#define FRAMES_ATRE_WORLD 30 +#define FRAMES_HARK_WORLD 30 +#define FRAMES_ORDOS_WORLD 30 +#define FRAMES_FREMEN 2 +#define FRAMES_FRIGATE 1 +#define FRAMES_DEATHHAND 16 +#define FRAMES_DEVASTATOR 1 +#define FRAMES_HARVESTER 13 +#define FRAMES_RADAR 10 +#define FRAMES_HIGHTECH 2 +#define FRAMES_SEIGETANK 1 +#define FRAMES_HEAVYFACT 7 +#define FRAMES_HEAVYINF 1 +#define FRAMES_INFANTRY 1 +#define FRAMES_IX 1 +#define FRAMES_LIGHTFACT 14 +#define FRAMES_COMBATTANK 1 +#define FRAMES_MCV 1 +#define FRAMES_DEVIATOR 1 +#define FRAMES_ORNI 1 +#define FRAMES_RAIDER 1 +#define FRAMES_PALACE 17 +#define FRAMES_REFINERY 6 +#define FRAMES_REPAIRBAY 1 +#define FRAMES_ROCKETTANK 1 +#define FRAMES_ROCKETTURRET 1 +#define FRAMES_SABOTEUR 1 +#define FRAMES_SARDAUKAR 10 +#define FRAMES_SLAB 1 +#define FRAMES_SONICTANK 1 +#define FRAMES_STARPORT 25 +#define FRAMES_SILO 4 +#define FRAMES_TRIKE 1 +#define FRAMES_TURRET 1 +#define FRAMES_WALL 1 +#define FRAMES_WINDTRAP 12 +#define FRAMES_WOR 8 +#define FRAMES_WORM 1 +#define FRAMES_QUAD 1 + +typedef enum +{ + Mentat_Concrete_Slab, + Mentat_Barracks, + Mentat_Carryall, + Mentat_Construction_Yard, + Mentat_Atreides_World, + Mentat_Harkonnen_World, + Mentat_Ordos_World, + Mentat_Fremen, + Mentat_Frigate, + Mentat_Deathhand, + Mentat_Devastator, + Mentat_Harvester, + Mentat_Radar, + Mentat_HighTech, + Mentat_SeigeTank, + Mentat_HeavyFactory, + Mentat_HeavyInfantry, + Mentat_Infantry, + Mentat_IX, + Mentat_LightFactory, + Mentat_CombatTank, + Mentat_MCV, + Mentat_Deviator, + Mentat_Ornithopter, + Mentat_Raider, + Mentat_Palace, + Mentat_Quad, + Mentat_Refinery, + Mentat_RepairBay, + Mentat_RocketTank, + Mentat_RocketTurret, + Mentat_Saboteur, + Mentat_Sardaukar, + Mentat_Slab, + Mentat_SonicTank, + Mentat_Starport, + Mentat_Silo, + Mentat_Trike, + Mentat_Turret, + Mentat_Wall, + Mentat_Windtrap, + Mentat_WOR, + Mentat_Worm, + Mentat_Entry_Unknown +} MENTAT_ENTRIES; + +typedef struct Mentat_Entry +{ + SDL_Surface *staticpic; + SDL_Surface **pic; + char *text; + char *fullText[512];//needed? + char *basePath; + + int frames; + int curFrame; + + int picID; + bool loaded; +} MentatEntry; + + + +class MentatClass +{ + +public: + MentatClass(); + ~MentatClass(); + void showMentat(); + bool doExit(); + void draw(); + void handlePress(int x, int y); + void handleCancelPress(int x, int y); + void handleRelease(int x, int y); + void handleCancelRelease(int x, int y); + void LoadData(); + void LoadMentatEntry(int entry, int frames, char *basePath, char *text); + void UnLoadMentatEntry(int entry); + void setMentatView(int entry); + char *getFramePath(char *basePath, int frame); + void createList(); + void checkMinMaxSelection(); + + void doBriefing(int level); + int doHouseChoice(); + bool doHouseInfo(int h); + + void makeTextSurface(int num); + + static void handleUp(void *val); + static void handleDown(void *val); + static void listButtonCallBack(void *val); + + static void yesCallback(void *val); + static void noCallback(void *val); + static void houseChoiceCallbackA(void *val); + static void houseChoiceCallbackO(void *val); + static void houseChoiceCallbackH(void *val); + inline void setHouseChoiceExitValue(int b) { houseChoiceExitValue = b; } + inline void setHouseChoiceValue(int b) { houseChoiceValue = b; } + + void handleInput(); + static void briefingButtonCallback(void *val); + inline void setBriefingRunning(bool b) { briefingRunning = b; } + + + void doUp(); + void doDown(); + + void updateTimers(); + void setHouse(int h); + + void UnloadTemporaryData(); + + SDL_Surface *loadImageFromZip(ZZIP_DIR* zzipdir, char *path); + +private: + Window *mentatWindow; + int house; + int currentViewID; + int frameTimer, mouthTimer, eyesTimer; + int eyesFrame, mouthFrame; + int talkLength; + int minSelection; + int maxSelection; + SDL_Surface *mentatSurface; + SDL_Surface *mentatExitSurf; SDL_Surface *mentatExitSurfPressed; - SDL_Surface *mentatProceedSurf; + SDL_Surface *mentatProceedSurf; SDL_Surface *mentatProceedSurfPressed; - - //SDL_Surface *textSurface; - SDL_Surface *shoulderSurface; - - SDL_Surface *eyesFrames[5]; - SDL_Surface *mouthFrames[5]; - SDL_Rect mentatPos, graphicPos, textPos, mouthPos, eyesPos, shoulderPos; - HBox mentatButtons; - VBox listBox; - Button buttonExit, buttonOK, listBt1, listBt2, listBt3, listBt4, listBt5, listBt6, listUp, listDown; - - BUILD_ITEM_DATA data1, data2, data3, data4, data5, data6;//holds a void * and a number, perfect for what we need - - ListIterator *selectionList; - - int loadedBefore; - - Mentat_Entry levelEntry; - bool inBriefing; - bool briefingRunning; - - bool inHouseChoice; - bool inInfoScreen; - - int houseChoiceExitValue; - int houseChoiceValue; - - Button houseAtre, houseOrdos, houseHark; - HBox houseButtons; - Window *houseChoiceWindow; - SDL_Surface *heraldSurf; - - Button yesButton, noButton;//buttons for yes and no - HBox yesNoButtons; - Window *houseInfoWindow; - Label textLabel; - - char *zipPath; -}; - -#endif // DUNE_MENTATCLASS_H - + + //SDL_Surface *textSurface; + SDL_Surface *shoulderSurface; + + SDL_Surface *eyesFrames[5]; + SDL_Surface *mouthFrames[5]; + SDL_Rect mentatPos, graphicPos, textPos, mouthPos, eyesPos, shoulderPos; + HBox mentatButtons; + VBox listBox; + Button buttonExit, buttonOK, listBt1, listBt2, listBt3, listBt4, listBt5, listBt6, listUp, listDown; + + BUILD_ITEM_DATA data1, data2, data3, data4, data5, data6;//holds a void * and a number, perfect for what we need + + ListIterator *selectionList; + + int loadedBefore; + + Mentat_Entry levelEntry; + bool inBriefing; + bool briefingRunning; + + bool inHouseChoice; + bool inInfoScreen; + + int houseChoiceExitValue; + int houseChoiceValue; + + Button houseAtre, houseOrdos, houseHark; + HBox houseButtons; + Window *houseChoiceWindow; + SDL_Surface *heraldSurf; + + Button yesButton, noButton;//buttons for yes and no + HBox yesNoButtons; + Window *houseInfoWindow; + Label textLabel; + + char *zipPath; +}; + +#endif // DUNE_MENTATCLASS_H + This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dv...@us...> - 2008-04-17 16:27:51
|
Revision: 133 http://dunelegacy.svn.sourceforge.net/dunelegacy/?rev=133&view=rev Author: dvalin Date: 2008-04-17 09:27:35 -0700 (Thu, 17 Apr 2008) Log Message: ----------- convert to unix style EOL Modified Paths: -------------- trunk/src/gui/Button.cpp Modified: trunk/src/gui/Button.cpp =================================================================== --- trunk/src/gui/Button.cpp 2007-12-08 16:04:58 UTC (rev 132) +++ trunk/src/gui/Button.cpp 2008-04-17 16:27:35 UTC (rev 133) @@ -1,77 +1,77 @@ -//#include "../sand.h" -//#include "gui.h" - -#include "gui/Button.h" -#include "Colours.h" -#include "ui.h" -#include "gui/Graphics.h" -#include "globals.h" -#include "SoundPlayerClass.h" +//#include "../sand.h" +//#include "gui.h" + +#include "gui/Button.h" +#include "Colours.h" +#include "ui.h" +#include "gui/Graphics.h" +#include "globals.h" +#include "SoundPlayerClass.h" #include "data.h" -#include "boost/signal.hpp" - -Button::Button() : Widget() -{ - mouseOver = pressed = toggled = toggler = false; - - rect.w = 20; - rect.h = 15; - - helpText[0] = '\0'; - helpTextSurface = NULL; - text[0] = '\0'; - textSurface = NULL; - - callbackClick = NULL; - callbackClick2 = NULL; - callBackData = NULL; - callbackCancel = NULL; - callbackCancel2 = NULL; - callBackCancelData = NULL; - - surface = NULL; - pressedSurface = NULL; - - hasProgress = false; - total = 100; - progress = 0; - - textColour = COLOUR_BLACK; - backGroundColour = COLOUR_WHITE; - pressedTextColour = COLOUR_BLACK; - borderColour = COLOUR_BLACK; - - transparent = false; +#include "boost/signal.hpp" + +Button::Button() : Widget() +{ + mouseOver = pressed = toggled = toggler = false; + + rect.w = 20; + rect.h = 15; + + helpText[0] = '\0'; + helpTextSurface = NULL; + text[0] = '\0'; + textSurface = NULL; + + callbackClick = NULL; + callbackClick2 = NULL; + callBackData = NULL; + callbackCancel = NULL; + callbackCancel2 = NULL; + callBackCancelData = NULL; + + surface = NULL; + pressedSurface = NULL; + + hasProgress = false; + total = 100; + progress = 0; + + textColour = COLOUR_BLACK; + backGroundColour = COLOUR_WHITE; + pressedTextColour = COLOUR_BLACK; + borderColour = COLOUR_BLACK; + + transparent = false; } -Button::Button(Uint32 x, Uint32 y, SDL_Surface * surf, SDL_Surface * surfPressed, bool visible) : Widget() -{ - mouseOver = pressed = toggled = toggler = false; - - rect.w = 20; - rect.h = 15; - - helpText[0] = '\0'; - helpTextSurface = NULL; - text[0] = '\0'; - textSurface = NULL; - - callbackClick = NULL; - callbackClick2 = NULL; - callBackData = NULL; - callbackCancel = NULL; - callbackCancel2 = NULL; - callBackCancelData = NULL; +Button::Button(Uint32 x, Uint32 y, SDL_Surface * surf, SDL_Surface * surfPressed, bool visible) : Widget() +{ + mouseOver = pressed = toggled = toggler = false; - surface = NULL; + rect.w = 20; + rect.h = 15; + + helpText[0] = '\0'; + helpTextSurface = NULL; + text[0] = '\0'; + textSurface = NULL; + + callbackClick = NULL; + callbackClick2 = NULL; + callBackData = NULL; + callbackCancel = NULL; + callbackCancel2 = NULL; + callBackCancelData = NULL; + + surface = NULL; pressedSurface = NULL; - if (surf != NULL) + if (surf != NULL) setSurface(surf, NULL); - if (surfPressed != NULL) - setPressedSurface(surfPressed, NULL); + if (surfPressed != NULL) + setPressedSurface(surfPressed, NULL); Widget::setX(x); @@ -82,413 +82,413 @@ Widget::setHeight(surf->h); Widget::setVisible(visible); - - hasProgress = false; - total = 100; - progress = 0; - - textColour = COLOUR_BLACK; - backGroundColour = COLOUR_WHITE; - pressedTextColour = COLOUR_BLACK; - borderColour = COLOUR_BLACK; - - transparent = false; -} - -Button::~Button() -{ - - //Surfaces are usually from the global surfaces data, so we dont want to free them, otherwise we'll crash - //might want to change this...copy the surfaces in?? -// if (pressedSurface) -// SDL_FreeSurface(surface); - -// if (surface) -// SDL_FreeSurface(surface); - - if (textSurface) - SDL_FreeSurface(textSurface); - - if (helpTextSurface) - SDL_FreeSurface(helpTextSurface); -} - -void Button::draw() -{ - if (visible) - { - if (surface && pressedSurface) - { - if(pressed) - { - SDL_Rect dest = rect; - dest.x += (rect.w - pressedSurfaceSrc.w)/2 + 1; - dest.y += (rect.h - pressedSurfaceSrc.h)/2 + 1; - SDL_BlitSurface(pressedSurface, &pressedSurfaceSrc, screen, &dest); - } - else - { - SDL_Rect dest = rect; - dest.x += (rect.w - surfaceSrc.w)/2 + 1; - dest.y += (rect.h - surfaceSrc.h)/2 + 1; - SDL_BlitSurface(surface, &surfaceSrc, screen, &dest); - } - } - else - { - if(!transparent) - { - if (pressed) //button has been pressed - { - //drawrect(screen, rect.x, rect.y, rect.x + rect.w, rect.y + rect.h, COLOUR_WHITE); - - SDL_FillRect(screen, &rect, borderColour); - - drawrect(screen, rect.x, rect.y, rect.x + rect.w, rect.y + rect.h, backGroundColour); - } - else - { - //SDL_FillRect(screen, &rect, COLOUR_WHITE); - - SDL_FillRect(screen, &rect, backGroundColour); - - drawrect(screen, rect.x, rect.y, rect.x + rect.w, rect.y + rect.h, borderColour); - } - } - - - if(surface) - { - SDL_Rect dest = rect; - dest.x += (rect.w - surfaceSrc.w)/2 + 1; - dest.y += (rect.h - surfaceSrc.h)/2 + 1; - - SDL_BlitSurface(surface, &surfaceSrc, screen, &dest); - } - } - - - if(hasProgress) - { - if (getPercentComplete() > 0) - { - int i, j; - - SDL_Rect dest = rect; - dest.x += (rect.w - surfaceSrc.w)/2 + 1; - dest.y += (rect.h - surfaceSrc.h)/2 + 1; - - if (!SDL_MUSTLOCK(screen) || (SDL_LockSurface(screen) == 0)) - { - for (i = 0; i < ((int)(getPercentComplete()*0.64)); i++)//should change 0.64 to work it out from rect size - for (j = i % 2; j < rect.h + 1; j+=2) - putpixel(screen, rect.x + i, rect.y + j, COLOUR_BLACK); - - if (SDL_MUSTLOCK(screen)) - SDL_UnlockSurface(screen); - } - } - } - - if (textSurface) - { - SDL_Rect textLocation; - textLocation.x = rect.x + rect.w/2 - textSurface->w/2; - textLocation.y = rect.y + rect.h/2 - textSurface->h/2; - SDL_BlitSurface(textSurface, NULL, screen, &textLocation); - } - - if (helpTextSurface && mouseOver) - { - SDL_Rect dest; - - dest.x = rect.x - helpTextSurface->w - 12; - dest.y = rect.y + 12; - dest.w = helpTextSurface->w + 4; - dest.h = helpTextSurface->h - 4; - SDL_FillRect(screen, &dest, COLOUR_BLACK); - drawrect(screen, dest.x, dest.y, dest.x + dest.w, dest.y + dest.h, COLOUR_YELLOW); - - dest.x = rect.x - helpTextSurface->w - 10; - dest.y = rect.y + 10; - dest.w = helpTextSurface->w; - dest.h = helpTextSurface->h; - SDL_BlitSurface(helpTextSurface, NULL, screen, &dest); - } - } -} - -void Button::handleMotion(Uint32 x, Uint32 y) -{ - if (enabled) - { - if (((x >= getX()) && (x < (getX() + getWidth()))) - && ((y >= getY()) && (y < (getY() + getHeight())))) - { - mouseLocationX = x; - mouseLocationY = y; - mouseOver = true; - } - else - { - mouseOver = false; - if (focusedWidget == this) - { - pressed = !pressed; - focusedWidget = NULL; - - if (text[0] != '\0') - { - if (textSurface) - SDL_FreeSurface(textSurface); //free the text then change its colour - if (pressed) - textSurface = TTF_RenderText_Solid(font[14], text, palette->colors[COLOUR_WHITE]); - else - textSurface = TTF_RenderText_Solid(font[14], text, palette->colors[textColour]); - } - } - } - } -} - -void Button::handleCancelPress(Uint32 x, Uint32 y) -{ - if (enabled && (callbackCancel || callbackCancel2) - && (((x >= getX()) && (x < (getX() + getWidth()))) - && ((y >= getY()) && (y < (getY() + getHeight()))))) - { - Widget::handleCancelPress(x, y); - setFocused(true); - - pressed = !pressed; - if (text[0] != '\0') - { - if (textSurface) - SDL_FreeSurface(textSurface); //free the text then change its colour - if (pressed) - textSurface = TTF_RenderText_Solid(font[14], text, palette->colors[COLOUR_WHITE]); - else - textSurface = TTF_RenderText_Solid(font[14], text, palette->colors[textColour]); - } - - SoundPlayer::Instance()->playSfxSound(Sound_buttonClick); - } -} - -void Button::handleCancelRelease(Uint32 x, Uint32 y) -{ - if (enabled && (callbackCancel || callbackCancel2) - && (((x >= getX()) && (x < (getX() + getWidth()))) - && ((y >= getY()) && (y < (getY() + getHeight()))))) - { - if (toggler) - toggled = !toggled; - - if (callbackCancel2) - callbackCancel2(callBackCancelData); - else if (callbackCancel) - callbackCancel(); - - if (!toggler || !toggled) - { - pressed = false; - - if (text[0] != '\0') - { - if (textSurface) - SDL_FreeSurface(textSurface); //free the text then change its colour - textSurface = TTF_RenderText_Solid(font[14], text, palette->colors[textColour]); - } - } - - setFocused(false); - } -} - -void Button::handlePress(Uint32 x, Uint32 y) -{ - if (enabled - && (((x >= getX()) && (x < (getX() + getWidth()))) - && ((y >= getY()) && (y < (getY() + getHeight()))))) - { - Widget::handlePress(x, y); - setFocused(true); - - pressed = !pressed; - if (text[0] != '\0') - { - if (textSurface) - SDL_FreeSurface(textSurface); //free the text then change its colour - if (pressed) - textSurface = TTF_RenderText_Solid(font[14], text, palette->colors[COLOUR_WHITE]); - else - textSurface = TTF_RenderText_Solid(font[14], text, palette->colors[textColour]); - } - + + hasProgress = false; + total = 100; + progress = 0; + + textColour = COLOUR_BLACK; + backGroundColour = COLOUR_WHITE; + pressedTextColour = COLOUR_BLACK; + borderColour = COLOUR_BLACK; + + transparent = false; +} + +Button::~Button() +{ + + //Surfaces are usually from the global surfaces data, so we dont want to free them, otherwise we'll crash + //might want to change this...copy the surfaces in?? +// if (pressedSurface) +// SDL_FreeSurface(surface); + +// if (surface) +// SDL_FreeSurface(surface); + + if (textSurface) + SDL_FreeSurface(textSurface); + + if (helpTextSurface) + SDL_FreeSurface(helpTextSurface); +} + +void Button::draw() +{ + if (visible) + { + if (surface && pressedSurface) + { + if(pressed) + { + SDL_Rect dest = rect; + dest.x += (rect.w - pressedSurfaceSrc.w)/2 + 1; + dest.y += (rect.h - pressedSurfaceSrc.h)/2 + 1; + SDL_BlitSurface(pressedSurface, &pressedSurfaceSrc, screen, &dest); + } + else + { + SDL_Rect dest = rect; + dest.x += (rect.w - surfaceSrc.w)/2 + 1; + dest.y += (rect.h - surfaceSrc.h)/2 + 1; + SDL_BlitSurface(surface, &surfaceSrc, screen, &dest); + } + } + else + { + if(!transparent) + { + if (pressed) //button has been pressed + { + //drawrect(screen, rect.x, rect.y, rect.x + rect.w, rect.y + rect.h, COLOUR_WHITE); + + SDL_FillRect(screen, &rect, borderColour); + + drawrect(screen, rect.x, rect.y, rect.x + rect.w, rect.y + rect.h, backGroundColour); + } + else + { + //SDL_FillRect(screen, &rect, COLOUR_WHITE); + + SDL_FillRect(screen, &rect, backGroundColour); + + drawrect(screen, rect.x, rect.y, rect.x + rect.w, rect.y + rect.h, borderColour); + } + } + + + if(surface) + { + SDL_Rect dest = rect; + dest.x += (rect.w - surfaceSrc.w)/2 + 1; + dest.y += (rect.h - surfaceSrc.h)/2 + 1; + + SDL_BlitSurface(surface, &surfaceSrc, screen, &dest); + } + } + + + if(hasProgress) + { + if (getPercentComplete() > 0) + { + int i, j; + + SDL_Rect dest = rect; + dest.x += (rect.w - surfaceSrc.w)/2 + 1; + dest.y += (rect.h - surfaceSrc.h)/2 + 1; + + if (!SDL_MUSTLOCK(screen) || (SDL_LockSurface(screen) == 0)) + { + for (i = 0; i < ((int)(getPercentComplete()*0.64)); i++)//should change 0.64 to work it out from rect size + for (j = i % 2; j < rect.h + 1; j+=2) + putpixel(screen, rect.x + i, rect.y + j, COLOUR_BLACK); + + if (SDL_MUSTLOCK(screen)) + SDL_UnlockSurface(screen); + } + } + } + + if (textSurface) + { + SDL_Rect textLocation; + textLocation.x = rect.x + rect.w/2 - textSurface->w/2; + textLocation.y = rect.y + rect.h/2 - textSurface->h/2; + SDL_BlitSurface(textSurface, NULL, screen, &textLocation); + } + + if (helpTextSurface && mouseOver) + { + SDL_Rect dest; + + dest.x = rect.x - helpTextSurface->w - 12; + dest.y = rect.y + 12; + dest.w = helpTextSurface->w + 4; + dest.h = helpTextSurface->h - 4; + SDL_FillRect(screen, &dest, COLOUR_BLACK); + drawrect(screen, dest.x, dest.y, dest.x + dest.w, dest.y + dest.h, COLOUR_YELLOW); + + dest.x = rect.x - helpTextSurface->w - 10; + dest.y = rect.y + 10; + dest.w = helpTextSurface->w; + dest.h = helpTextSurface->h; + SDL_BlitSurface(helpTextSurface, NULL, screen, &dest); + } + } +} + +void Button::handleMotion(Uint32 x, Uint32 y) +{ + if (enabled) + { + if (((x >= getX()) && (x < (getX() + getWidth()))) + && ((y >= getY()) && (y < (getY() + getHeight())))) + { + mouseLocationX = x; + mouseLocationY = y; + mouseOver = true; + } + else + { + mouseOver = false; + if (focusedWidget == this) + { + pressed = !pressed; + focusedWidget = NULL; + + if (text[0] != '\0') + { + if (textSurface) + SDL_FreeSurface(textSurface); //free the text then change its colour + if (pressed) + textSurface = TTF_RenderText_Solid(font[14], text, palette->colors[COLOUR_WHITE]); + else + textSurface = TTF_RenderText_Solid(font[14], text, palette->colors[textColour]); + } + } + } + } +} + +void Button::handleCancelPress(Uint32 x, Uint32 y) +{ + if (enabled && (callbackCancel || callbackCancel2) + && (((x >= getX()) && (x < (getX() + getWidth()))) + && ((y >= getY()) && (y < (getY() + getHeight()))))) + { + Widget::handleCancelPress(x, y); + setFocused(true); + + pressed = !pressed; + if (text[0] != '\0') + { + if (textSurface) + SDL_FreeSurface(textSurface); //free the text then change its colour + if (pressed) + textSurface = TTF_RenderText_Solid(font[14], text, palette->colors[COLOUR_WHITE]); + else + textSurface = TTF_RenderText_Solid(font[14], text, palette->colors[textColour]); + } + SoundPlayer::Instance()->playSfxSound(Sound_buttonClick); - } - -} - -void Button::handleRelease(Uint32 x, Uint32 y) -{ - if (enabled - && (((x >= getX()) && (x < (getX() + getWidth()))) - && ((y >= getY()) && (y < (getY() + getHeight()))))) - { - if (toggler) - toggled = !toggled; - - setFocused(false); - - if (toggler || pressed) - { - if (callbackClick2) - callbackClick2(callBackData); - else if (callbackClick) - callbackClick(); - } - - if (!toggler || !toggled) - { - pressed = false; - - if (text[0] != '\0') - { - if (textSurface) - SDL_FreeSurface(textSurface); //free the text then change its colour - textSurface = TTF_RenderText_Solid(font[14], text, palette->colors[textColour]); - } +} + +void Button::handleCancelRelease(Uint32 x, Uint32 y) +{ + if (enabled && (callbackCancel || callbackCancel2) + && (((x >= getX()) && (x < (getX() + getWidth()))) + && ((y >= getY()) && (y < (getY() + getHeight()))))) + { + if (toggler) + toggled = !toggled; + + if (callbackCancel2) + callbackCancel2(callBackCancelData); + else if (callbackCancel) + callbackCancel(); + + if (!toggler || !toggled) + { + pressed = false; + + if (text[0] != '\0') + { + if (textSurface) + SDL_FreeSurface(textSurface); //free the text then change its colour + textSurface = TTF_RenderText_Solid(font[14], text, palette->colors[textColour]); + } } - onClick(); - } -} - -void Button::setCallBack(void (*newCallback)()) -{ - callbackClick = newCallback; - callbackClick2 = NULL; -} - -void Button::setCallBack(void (*newCallback)(void* data), void* newData) -{ - callbackClick2 = newCallback; - callbackClick = NULL; - callBackData = newData; -} - -void Button::setCallBackCancel(void (*newCallback)()) -{ - callbackCancel = newCallback; - callbackCancel2 = NULL; -} - -void Button::setCallBackCancel(void (*newCallback)(void* data), void* newData) -{ - callbackCancel2 = newCallback; - callbackCancel = NULL; - callBackCancelData = newData; -} - -void Button::setHelpText(char* newText) -{ - strncpy(helpText, newText, MAX_LINE); - - if (helpTextSurface) - SDL_FreeSurface(helpTextSurface); - helpTextSurface = TTF_RenderText_Solid(font[14], helpText, palette->colors[COLOUR_YELLOW]); -} - -void Button::setSurface(SDL_Surface* newSurface, SDL_Rect* src) -{ - surface = newSurface; - if (src == NULL) - { - surfaceSrc.x = surfaceSrc.y = 0; - surfaceSrc.w = newSurface->w; - surfaceSrc.h = newSurface->h; - } - else - surfaceSrc = *src; -} - -void Button::setPressedSurface(SDL_Surface* newSurface, SDL_Rect* src) -{ - pressedSurface = newSurface; - if (src == NULL) - { - pressedSurfaceSrc.x = pressedSurfaceSrc.y = 0; - pressedSurfaceSrc.w = newSurface->w; - pressedSurfaceSrc.h = newSurface->h; - } - else - pressedSurfaceSrc = *src; -} - -void Button::setText(char* newText) -{ - strncpy(text, newText, MAX_LINE); - - if (textSurface) - SDL_FreeSurface(textSurface); - //textSurface = TTF_RenderText_Solid(font[14], text, palette->colors[COLOUR_BLACK]); - textSurface = TTF_RenderText_Solid(font[14], text, palette->colors[textColour]); -} - -void Button::setToggled(bool toggle) -{ - toggled = pressed = toggle; - - if (text[0] != '\0') - { - if (textSurface) - SDL_FreeSurface(textSurface); //free the text then change its colour - if (pressed) - textSurface = TTF_RenderText_Solid(font[14], text, palette->colors[COLOUR_WHITE]); - else - textSurface = TTF_RenderText_Solid(font[14], text, palette->colors[textColour]);//used to be black - } - if (this == focusedWidget) - focusedWidget = NULL; -} - -bool Button::textEquals(char* checkText) -{ - return (strcmp(checkText, text) == 0); -} - -char* Button::getText() -{ - return text; -} - -int Button::getProgress() -{ - return progress; -} -void Button::setProgress(int i) -{ - progress = i; -} - -void Button::setTotalProgress(int i) -{ - total = i; -} - -void Button::setIsProgress(bool i) -{ - hasProgress = i; -} - -bool Button::isProgress() -{ - return hasProgress; -} - -double Button::getPercentComplete() -{ - return progress*100.0/total; -} - + + setFocused(false); + } +} + +void Button::handlePress(Uint32 x, Uint32 y) +{ + if (enabled + && (((x >= getX()) && (x < (getX() + getWidth()))) + && ((y >= getY()) && (y < (getY() + getHeight()))))) + { + Widget::handlePress(x, y); + setFocused(true); + + pressed = !pressed; + if (text[0] != '\0') + { + if (textSurface) + SDL_FreeSurface(textSurface); //free the text then change its colour + if (pressed) + textSurface = TTF_RenderText_Solid(font[14], text, palette->colors[COLOUR_WHITE]); + else + textSurface = TTF_RenderText_Solid(font[14], text, palette->colors[textColour]); + } + + SoundPlayer::Instance()->playSfxSound(Sound_buttonClick); + + } + +} + +void Button::handleRelease(Uint32 x, Uint32 y) +{ + if (enabled + && (((x >= getX()) && (x < (getX() + getWidth()))) + && ((y >= getY()) && (y < (getY() + getHeight()))))) + { + if (toggler) + toggled = !toggled; + + setFocused(false); + + if (toggler || pressed) + { + if (callbackClick2) + callbackClick2(callBackData); + else if (callbackClick) + callbackClick(); + } + + if (!toggler || !toggled) + { + pressed = false; + + if (text[0] != '\0') + { + if (textSurface) + SDL_FreeSurface(textSurface); //free the text then change its colour + textSurface = TTF_RenderText_Solid(font[14], text, palette->colors[textColour]); + } + } + onClick(); + } +} + +void Button::setCallBack(void (*newCallback)()) +{ + callbackClick = newCallback; + callbackClick2 = NULL; +} + +void Button::setCallBack(void (*newCallback)(void* data), void* newData) +{ + callbackClick2 = newCallback; + callbackClick = NULL; + callBackData = newData; +} + +void Button::setCallBackCancel(void (*newCallback)()) +{ + callbackCancel = newCallback; + callbackCancel2 = NULL; +} + +void Button::setCallBackCancel(void (*newCallback)(void* data), void* newData) +{ + callbackCancel2 = newCallback; + callbackCancel = NULL; + callBackCancelData = newData; +} + +void Button::setHelpText(char* newText) +{ + strncpy(helpText, newText, MAX_LINE); + + if (helpTextSurface) + SDL_FreeSurface(helpTextSurface); + helpTextSurface = TTF_RenderText_Solid(font[14], helpText, palette->colors[COLOUR_YELLOW]); +} + +void Button::setSurface(SDL_Surface* newSurface, SDL_Rect* src) +{ + surface = newSurface; + if (src == NULL) + { + surfaceSrc.x = surfaceSrc.y = 0; + surfaceSrc.w = newSurface->w; + surfaceSrc.h = newSurface->h; + } + else + surfaceSrc = *src; +} + +void Button::setPressedSurface(SDL_Surface* newSurface, SDL_Rect* src) +{ + pressedSurface = newSurface; + if (src == NULL) + { + pressedSurfaceSrc.x = pressedSurfaceSrc.y = 0; + pressedSurfaceSrc.w = newSurface->w; + pressedSurfaceSrc.h = newSurface->h; + } + else + pressedSurfaceSrc = *src; +} + +void Button::setText(char* newText) +{ + strncpy(text, newText, MAX_LINE); + + if (textSurface) + SDL_FreeSurface(textSurface); + //textSurface = TTF_RenderText_Solid(font[14], text, palette->colors[COLOUR_BLACK]); + textSurface = TTF_RenderText_Solid(font[14], text, palette->colors[textColour]); +} + +void Button::setToggled(bool toggle) +{ + toggled = pressed = toggle; + + if (text[0] != '\0') + { + if (textSurface) + SDL_FreeSurface(textSurface); //free the text then change its colour + if (pressed) + textSurface = TTF_RenderText_Solid(font[14], text, palette->colors[COLOUR_WHITE]); + else + textSurface = TTF_RenderText_Solid(font[14], text, palette->colors[textColour]);//used to be black + } + if (this == focusedWidget) + focusedWidget = NULL; +} + +bool Button::textEquals(char* checkText) +{ + return (strcmp(checkText, text) == 0); +} + +char* Button::getText() +{ + return text; +} + +int Button::getProgress() +{ + return progress; +} +void Button::setProgress(int i) +{ + progress = i; +} + +void Button::setTotalProgress(int i) +{ + total = i; +} + +void Button::setIsProgress(bool i) +{ + hasProgress = i; +} + +bool Button::isProgress() +{ + return hasProgress; +} + +double Button::getPercentComplete() +{ + return progress*100.0/total; +} + This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <shu...@us...> - 2007-12-08 16:05:05
|
Revision: 132 http://dunelegacy.svn.sourceforge.net/dunelegacy/?rev=132&view=rev Author: shutdownrunner Date: 2007-12-08 08:04:58 -0800 (Sat, 08 Dec 2007) Log Message: ----------- * Used shared_ptr more frequently to avoid memory leaks * Nothing more, apart from being less leaky Modified Paths: -------------- branches/dunks/SConstruct branches/dunks/include/Application.h branches/dunks/include/Font.h branches/dunks/include/Gfx.h branches/dunks/include/IntroState.h branches/dunks/include/MainMenu.h branches/dunks/include/gui2/Button.h branches/dunks/include/gui2/Container.h branches/dunks/include/gui2/Label.h branches/dunks/include/gui2/Widget.h branches/dunks/include/pakfile/Wsafile.h branches/dunks/src/Application.cpp branches/dunks/src/Font.cpp branches/dunks/src/Gfx.cpp branches/dunks/src/IntroState.cpp branches/dunks/src/MainMenu.cpp branches/dunks/src/ResMan.cpp branches/dunks/src/SConscript branches/dunks/src/gui2/Button.cpp branches/dunks/src/gui2/Container.cpp branches/dunks/src/gui2/Label.cpp branches/dunks/src/pakfile/Cpsfile.cpp branches/dunks/src/pakfile/Icnfile.cpp branches/dunks/src/pakfile/Shpfile.cpp branches/dunks/src/pakfile/Wsafile.cpp branches/dunks/src/pakview.cpp Modified: branches/dunks/SConstruct =================================================================== --- branches/dunks/SConstruct 2007-08-14 18:24:08 UTC (rev 131) +++ branches/dunks/SConstruct 2007-12-08 16:04:58 UTC (rev 132) @@ -25,7 +25,7 @@ if sys.platform != "win32": env.ParseConfig('sdl-config --cflags --libs') env.ParseConfig('pkg-config --cflags --libs zziplib') - env.Append(CCFLAGS=["-Wall"]) #, "-Werror"]) + env.Append(CCFLAGS=["-Wall", "-O0"]) #, "-Werror"]) #env.Append(CCFLAGS=["-Wall", "-Werror", "-O2", "-ffast-math", "-funroll-loops"]) #env.Append(LINKFLAGS = ["-ffast-math"]) Modified: branches/dunks/include/Application.h =================================================================== --- branches/dunks/include/Application.h 2007-08-14 18:24:08 UTC (rev 131) +++ branches/dunks/include/Application.h 2007-12-08 16:04:58 UTC (rev 132) @@ -34,7 +34,7 @@ void Die(); - inline SDL_Surface* Screen() { return m_screen; } + inline Image * Screen() { return m_screen; } inline Uint16 CursorX() { return m_cursorX; } inline Uint16 CursorY() { return m_cursorY; } @@ -45,9 +45,6 @@ Container* RootWidget() { return m_rootWidget; } - void Blit(SDL_Surface* surface, SDL_Rect* src, SDL_Rect* dest); - void BlitCentered(SDL_Surface* surface, SDL_Rect* src=NULL); - void SetPalette(); SDL_Palette* GetCurrentPalette() { return m_currentPalette; } @@ -69,7 +66,7 @@ void HandleEvents(); void BlitCursor(); - SDL_Surface* m_screen; + Image * m_screen; SDL_Palette* m_currentPalette; StateMachine* m_rootState; @@ -80,7 +77,7 @@ Uint16 m_cursorX, m_cursorY; Cursor m_cursorFrame; - SDL_Surface* m_cursor; + ImagePtr m_cursor; Uint32 m_clearColor; }; Modified: branches/dunks/include/Font.h =================================================================== --- branches/dunks/include/Font.h 2007-08-14 18:24:08 UTC (rev 131) +++ branches/dunks/include/Font.h 2007-12-08 16:04:58 UTC (rev 132) @@ -1,6 +1,7 @@ #ifndef DUNE_FONT_H #define DUNE_FONT_H +#include "Gfx.h" #include "singleton.h" #include "SDL.h" #include "SDL_ttf.h" @@ -46,7 +47,7 @@ ~Font(); void extents(const char* text, Uint16& w, Uint16& h); - void render(const char* text, SDL_Surface* surface, int x, int y, Uint8 paloff); + void render(const char* text, ImagePtr image, int x, int y, Uint8 paloff); private: FNTHeader* m_header; Modified: branches/dunks/include/Gfx.h =================================================================== --- branches/dunks/include/Gfx.h 2007-08-14 18:24:08 UTC (rev 131) +++ branches/dunks/include/Gfx.h 2007-12-08 16:04:58 UTC (rev 132) @@ -633,11 +633,11 @@ /*! @param size size of the new image */ - ImagePtr getResized(ConstUPoint size) +/* ImagePtr getResized(ConstUPoint size) { return ImagePtr(new Image(resizeSurface(surface, size.x, size.y))); }; - +*/ //! Set colorkey /*! Modified: branches/dunks/include/IntroState.h =================================================================== --- branches/dunks/include/IntroState.h 2007-08-14 18:24:08 UTC (rev 131) +++ branches/dunks/include/IntroState.h 2007-12-08 16:04:58 UTC (rev 132) @@ -1,6 +1,7 @@ #ifndef DUNE_INTROSTATE_H #define DUNE_INTROSTATE_H +#include "Gfx.h" #include "State.h" #include "gui2/Button.h" #include "pakfile/Wsafile.h" @@ -45,11 +46,11 @@ Transition m_transition_out; bool mb_finished; - Wsafile *m_wsa; + WsafilePtr m_wsa; int m_currentFrame; float m_frametime; - SDL_Surface* m_animSurface, *m_scaledSurface; + ImagePtr m_animSurface, m_scaledSurface; SDL_Color* m_transitionPalette; void setupTransitionIn(); Modified: branches/dunks/include/MainMenu.h =================================================================== --- branches/dunks/include/MainMenu.h 2007-08-14 18:24:08 UTC (rev 131) +++ branches/dunks/include/MainMenu.h 2007-12-08 16:04:58 UTC (rev 132) @@ -23,7 +23,7 @@ private: VBox* m_vbox; Rect m_rect; - SDL_Surface * m_surf; + ImagePtr m_surf; BoringButton* m_butSingle; BoringButton* m_butMulti; BoringButton* m_butMapEd; Modified: branches/dunks/include/gui2/Button.h =================================================================== --- branches/dunks/include/gui2/Button.h 2007-08-14 18:24:08 UTC (rev 131) +++ branches/dunks/include/gui2/Button.h 2007-12-08 16:04:58 UTC (rev 132) @@ -18,19 +18,18 @@ { public: GraphicButton(); - GraphicButton(SDL_Surface* normal, SDL_Surface* pressed=NULL); + GraphicButton(ImagePtr normal, ImagePtr pressed); - void setGraphics(SDL_Surface* normal, - SDL_Surface* pressed = NULL); + void setGraphics(ImagePtr normal, ImagePtr pressed); - virtual void draw(SDL_Surface* dest, SPoint off); + virtual void draw(Image * dest, SPoint off); virtual bool handleButtonDown(Uint8 button, SPoint p); virtual bool handleButtonUp(Uint8 button, SPoint p); protected: - SDL_Surface* m_surfNormal; - SDL_Surface* m_surfPressed; + ImagePtr m_surfNormal; + ImagePtr m_surfPressed; bool m_pressed; }; Modified: branches/dunks/include/gui2/Container.h =================================================================== --- branches/dunks/include/gui2/Container.h 2007-08-14 18:24:08 UTC (rev 131) +++ branches/dunks/include/gui2/Container.h 2007-12-08 16:04:58 UTC (rev 132) @@ -9,7 +9,7 @@ public: typedef std::list<Widget*> WidgetList; - virtual void draw(SDL_Surface* dest, SPoint offset); + virtual void draw(Image * dest, SPoint offset); virtual bool handleMotion(SPoint p); virtual bool handleButtonDown(Uint8 button, SPoint p); Modified: branches/dunks/include/gui2/Label.h =================================================================== --- branches/dunks/include/gui2/Label.h 2007-08-14 18:24:08 UTC (rev 131) +++ branches/dunks/include/gui2/Label.h 2007-12-08 16:04:58 UTC (rev 132) @@ -22,11 +22,11 @@ ~Label(); //@} - virtual void draw(SDL_Surface* dest, SPoint off); + virtual void draw(Image * dest, SPoint off); protected: - SDL_Surface * m_surface; + ImagePtr m_surface; std::string m_caption; }; Modified: branches/dunks/include/gui2/Widget.h =================================================================== --- branches/dunks/include/gui2/Widget.h 2007-08-14 18:24:08 UTC (rev 131) +++ branches/dunks/include/gui2/Widget.h 2007-12-08 16:04:58 UTC (rev 132) @@ -15,7 +15,7 @@ virtual ~Widget(); //@} - virtual void draw(SDL_Surface* dest, SPoint off) {} + virtual void draw(Image * dest, SPoint off) {} //! @name Event handling functions //@{ Modified: branches/dunks/include/pakfile/Wsafile.h =================================================================== --- branches/dunks/include/pakfile/Wsafile.h 2007-08-14 18:24:08 UTC (rev 131) +++ branches/dunks/include/pakfile/Wsafile.h 2007-12-08 16:04:58 UTC (rev 132) @@ -1,11 +1,16 @@ #ifndef WSAFILE_H_INCLUDED #define WSAFILE_H_INCLUDED +#include "Gfx.h" #include "pakfile/Decode.h" #include "SDL.h" -//extern SDL_Palette* palette; +#include <boost/shared_ptr.hpp> +class Wsafile; + +typedef boost::shared_ptr<Wsafile> WsafilePtr; + class Wsafile : public Decode { public: @@ -13,7 +18,7 @@ SDL_Surface* lastframe = NULL); ~Wsafile(); - SDL_Surface * getPicture(Uint32 FrameNumber, SDL_Palette *palette); + Image * getPicture(Uint32 FrameNumber, SDL_Palette *palette); inline int getNumFrames() { return (int) NumFrames; }; inline Uint32 getFramesPer1024ms() { return FramesPer1024ms; }; @@ -32,7 +37,7 @@ Uint16 SizeX; Uint16 SizeY; Uint32 FramesPer1024ms; - float fps; + float fps; }; #endif // WSAFILE_H_INCLUDED Modified: branches/dunks/src/Application.cpp =================================================================== --- branches/dunks/src/Application.cpp 2007-08-14 18:24:08 UTC (rev 131) +++ branches/dunks/src/Application.cpp 2007-12-08 16:04:58 UTC (rev 132) @@ -23,7 +23,7 @@ #include "Font.h" #include "TopLevelState.h" //#include "DataFile.h" - +#include "Gfx.h" #include "pakfile/Palette.h" #include "pakfile/Shpfile.h" #include "pakfile/Cpsfile.h" @@ -40,7 +40,6 @@ { m_running = false; m_rootState = NULL; - m_screen = NULL; m_cursorX = 0; m_cursorY = 0; @@ -55,13 +54,13 @@ delete m_rootState; delete m_rootWidget; - FontManager::Destroy(); + //FontManager::Destroy(); //destroyDataFile(); //MentatClass::Destroy(); //Mix_CloseAudio(); //SDLNet_Quit(); - SDL_Quit(); + //SDL_Quit(); } void Application::Init() @@ -213,10 +212,10 @@ assert(pal != NULL); printf("setting palette %d colors\n", pal->ncolors); - assert( SDL_SetColors(m_screen, pal->colors, 0, pal->ncolors) == 1 ); + assert( SDL_SetColors(m_screen->getSurface(), pal->colors, 0, pal->ncolors) == 1 ); m_currentPalette = pal; - SDL_Palette* palette = m_screen->format->palette; + SDL_Palette* palette = m_screen->getSurface()->format->palette; palette = m_currentPalette; } @@ -231,13 +230,15 @@ if (set->m_fullscreen) videoFlags |= SDL_FULLSCREEN; - m_screen = SDL_SetVideoMode(set->m_width, set->m_height, - 8, videoFlags); - if(!m_screen) + SDL_Surface * surf = SDL_SetVideoMode(set->m_width, set->m_height, 8, videoFlags); + + if(!surf) { fprintf(stderr, "ERROR: Couldn't set video mode: %s\n", SDL_GetError()); Die(); }; + + m_screen = new Image(surf); // reset the palette if we've got one if (m_currentPalette != NULL) @@ -299,7 +300,7 @@ Shpfile mouse (data, len); - m_cursor = mouse.getPicture(0); + m_cursor.reset(new Image(mouse.getPicture(0))); /* @@ -340,7 +341,7 @@ while (m_running) { - SDL_FillRect(m_screen, NULL, m_clearColor); + SDL_FillRect(m_screen->getSurface(), NULL, m_clearColor); HandleEvents(); @@ -378,7 +379,7 @@ } #endif - SDL_Flip(m_screen); + SDL_Flip(m_screen->getSurface()); fps_frames ++; @@ -405,7 +406,7 @@ switch (event.type) { case SDL_QUIT: - printf("QUIT!\n"); + fprintf(stderr,"QUIT!\n"); m_running = false; break; case SDL_MOUSEMOTION: @@ -435,8 +436,8 @@ void Application::BlitCursor() { - SDL_Rect dest; - SDL_Surface* surface = m_cursor; // being lazy, rename me + UPoint dest; + SDL_Surface * surface = m_cursor->getSurface(); // being lazy, rename me dest.x = m_cursorX; dest.y = m_cursorY; @@ -461,31 +462,8 @@ dest.y -= surface->h/2; } - SDL_BlitSurface(surface, NULL, m_screen, &dest); -} + m_screen->blitFrom(m_cursor.get(), dest); - -void Application::Blit(SDL_Surface* surface, SDL_Rect* src, SDL_Rect* dest) -{ - assert( SDL_BlitSurface(surface, src, m_screen, dest) == 0 ); + //SDL_BlitSurface(surface, NULL, m_screen, &dest); } -void Application::BlitCentered(SDL_Surface* surface, SDL_Rect* src) -{ - SDL_Rect dest; - if (src == NULL) - { - dest.x = (Settings::Instance()->m_width / 2) - (surface->w / 2); - dest.y = (Settings::Instance()->m_height / 2) - (surface->h / 2); - } - else - { - dest.x = (Settings::Instance()->m_width / 2) - (src->w / 2); - dest.y = (Settings::Instance()->m_height / 2) - (src->h / 2); - }; - - //printf("blitting %d %d %d %d\n", dest.x, dest.y, surface->w, surface->h); - Blit(surface, src, &dest); -} - - Modified: branches/dunks/src/Font.cpp =================================================================== --- branches/dunks/src/Font.cpp 2007-08-14 18:24:08 UTC (rev 131) +++ branches/dunks/src/Font.cpp 2007-12-08 16:04:58 UTC (rev 132) @@ -32,10 +32,13 @@ }; } -void Font::render(const char* text, SDL_Surface* surface, int offx, int offy, Uint8 paloff) +void Font::render(const char* text, ImagePtr image, int offx, int offy, Uint8 paloff) { FNTCharacter* ch; byte* bitmap; + + SDL_Surface * surface = image->getSurface(); + Uint8* pixels = (Uint8*)surface->pixels; for (unsigned int c=0; c!=strlen(text); c++) Modified: branches/dunks/src/Gfx.cpp =================================================================== --- branches/dunks/src/Gfx.cpp 2007-08-14 18:24:08 UTC (rev 131) +++ branches/dunks/src/Gfx.cpp 2007-12-08 16:04:58 UTC (rev 132) @@ -38,7 +38,7 @@ }; // copy palette from the screen (otherwise you'll get only black image) - SDL_SetColors(surface, Application::Instance()->Screen()->format->palette->colors, 0, 256); + SDL_SetColors(surface, Application::Instance()->Screen()->getSurface()->format->palette->colors, 0, 256); } Image::~Image() { @@ -53,26 +53,21 @@ return surface; } -// TODO: once Application::Instance()->Screen() returns ImagePtr, change -// these methods to use Image::blitTo ! void Image::blitToScreen(ConstRect srcRect, ConstUPoint dstPoint) const { - Rect dstRect(Rect(dstPoint, getSize())); - SDL_BlitSurface(surface, const_cast<SDL_Rect *>(static_cast<const SDL_Rect *>(&srcRect)), Application::Instance()->Screen(), &dstRect); + blitTo(Application::Instance()->Screen(), srcRect, dstPoint); } void Image::blitToScreen(ConstUPoint dstPoint) const { - Rect dstRect(Rect(dstPoint, getSize())); - SDL_BlitSurface(surface, NULL, Application::Instance()->Screen(), &dstRect); + blitTo(Application::Instance()->Screen(), dstPoint); } void Image::blitToScreen() const { - SDL_BlitSurface(surface, NULL, Application::Instance()->Screen(), NULL); + blitTo(Application::Instance()->Screen()); } void Image::blitToScreenCentered() const { - Rect dstRect(Rect(UPoint(Application::Instance()->Screen()->w, Application::Instance()->Screen()->h)/2 - getSize()/2, getSize())); - SDL_BlitSurface(surface, NULL, Application::Instance()->Screen(), &dstRect); + blitToCentered(Application::Instance()->Screen()); } @@ -134,7 +129,7 @@ void putPixel(SDL_Surface *surface, int x, int y, Uint32 color) { assert(surface != NULL); - SDL_Surface *screen = Application::Instance()->Screen(); + SDL_Surface *screen = Application::Instance()->Screen()->getSurface(); if (x >= 0 && x < screen->w && y >=0 && y < screen->h) { int bpp = surface->format->BytesPerPixel; Modified: branches/dunks/src/IntroState.cpp =================================================================== --- branches/dunks/src/IntroState.cpp 2007-08-14 18:24:08 UTC (rev 131) +++ branches/dunks/src/IntroState.cpp 2007-12-08 16:04:58 UTC (rev 132) @@ -25,6 +25,8 @@ void IntroState::Frame::Load(Frame* lastframe) { + SDL_Palette* palette = Application::Instance()->Screen()->getSurface()->format->palette; + printf("intro loading %s\n", m_filename.c_str()); int len; @@ -34,32 +36,20 @@ if (m_continuation) { - m_wsa = new Wsafile(data, len, lastframe->m_animSurface); + m_wsa.reset(new Wsafile(data, len, lastframe->m_animSurface->getSurface())); } else { - m_wsa = new Wsafile(data, len); + m_wsa.reset(new Wsafile(data, len)); } m_frametime = 0; m_currentFrame = 0; mb_finished = false; - SDL_Palette* palette = Application::Instance()->Screen()->format->palette; - m_animSurface = m_wsa->getPicture(m_currentFrame, palette); + m_animSurface.reset(m_wsa->getPicture(m_currentFrame, palette)); + m_scaledSurface = m_animSurface->getResized(2.0); - SDL_FreeSurface(m_scaledSurface); - - m_scaledSurface = - SDL_CreateRGBSurface(SDL_SWSURFACE, - m_animSurface->w*2, - m_animSurface->h*2, - 8, - 0,0,0,0); - - SDL_SetColors(m_scaledSurface, palette->colors, 0, palette->ncolors); - - m_scaledSurface = resizeSurface(m_animSurface, 2); } bool IntroState::Frame::Execute(float dt) @@ -84,16 +74,16 @@ break; }; - assert(m_scaledSurface != NULL); - - Application::Instance()->BlitCentered(m_scaledSurface); - + m_scaledSurface->blitToScreenCentered(); + return mb_finished; } void IntroState::Frame::doPlaying(float dt) { + SDL_Palette* palette = Application::Instance()->Screen()->getSurface()->format->palette; + m_frametime += dt; if (m_frametime > m_wsa->getFPS()) @@ -106,21 +96,8 @@ } else { - SDL_Palette* palette = Application::Instance()->Screen()->format->palette; - m_animSurface = m_wsa->getPicture(m_currentFrame, palette); - - SDL_FreeSurface(m_scaledSurface); - - m_scaledSurface = - SDL_CreateRGBSurface(SDL_SWSURFACE, - m_animSurface->w*2, - m_animSurface->h*2, - 8, - 0,0,0,0); - - SDL_SetColors(m_scaledSurface, palette->colors, 0, palette->ncolors); - - m_scaledSurface = resizeSurface(m_animSurface, 2); + m_animSurface.reset(m_wsa->getPicture(m_currentFrame, palette)); + m_scaledSurface = m_animSurface->getResized(2.0); }; }; } @@ -142,7 +119,7 @@ { m_transitionPalette = new SDL_Color[256]; memcpy((unsigned char*)m_transitionPalette, - Application::Instance()->Screen()->format->palette->colors, + Application::Instance()->Screen()->getSurface()->format->palette->colors, sizeof(SDL_Color) * 256); } @@ -162,7 +139,7 @@ if (m_transitionPalette == NULL) setupTransitionOut(); bool done = true; - SDL_Surface* screen = m_scaledSurface; //Application::Instance()->Screen(); + SDL_Surface* screen = m_scaledSurface->getSurface(); //Application::Instance()->Screen(); SDL_Color* col = m_transitionPalette; const int fadeAmt = 3; @@ -278,6 +255,7 @@ void IntroState::SkipIntro() { mp_parent->PopState(); + } void IntroState::JustMadeActive() @@ -296,7 +274,7 @@ bool IntroState::next() { - printf("loading next..\n"); + fprintf(stderr, "loading next..\n"); IntroList::iterator it = m_wsaNames.begin(); if (it == m_wsaNames.end() ) { Modified: branches/dunks/src/MainMenu.cpp =================================================================== --- branches/dunks/src/MainMenu.cpp 2007-08-14 18:24:08 UTC (rev 131) +++ branches/dunks/src/MainMenu.cpp 2007-12-08 16:04:58 UTC (rev 132) @@ -1,6 +1,7 @@ #include "MainMenu.h" #include "Application.h" +#include "Gfx.h" //#include "DataFile.h" #include "Settings.h" #include "ResMan.h" @@ -90,46 +91,27 @@ int len; unsigned char * data = ResMan::Instance()->readFile("MENTAT:FARTR.WSA", &len); - SDL_Palette* palette = Application::Instance()->Screen()->format->palette; + SDL_Palette* palette = Application::Instance()->Screen()->getSurface()->format->palette; - Wsafile * m_wsa = new Wsafile(data, len); + WsafilePtr m_wsa (new Wsafile(data, len)); - SDL_Surface * tmp = copySurface(m_wsa->getPicture(1, palette)); - - m_surf = SDL_CreateRGBSurface(SDL_SWSURFACE, 258, 65, 8,0,0,0,0); - - SDL_SetColors(m_surf, palette->colors, 0, palette->ncolors); - + ImagePtr tmp (m_wsa->getPicture(1, palette)); + m_surf.reset(new Image(UPoint(258, 65))); Rect src (6,31, 82, 65); + m_surf->blitFrom(tmp.get(), src, UPoint(0, 0)); - Rect cp(0, 0, 82, 65); - - SDL_BlitSurface(tmp, &src, m_surf, &cp); - - data = ResMan::Instance()->readFile("MENTAT:FHARK.WSA", &len); + m_wsa.reset(new Wsafile(data, len)); + tmp.reset(m_wsa->getPicture(1, palette)); + m_surf->blitFrom(tmp.get(), src, UPoint(88, 0)); - m_wsa = new Wsafile(data, len); - tmp = copySurface(m_wsa->getPicture(1, palette)); - - cp.setPosition(SPoint(88, 0)); - - SDL_BlitSurface(tmp, &src, m_surf, &cp); - data = ResMan::Instance()->readFile("MENTAT:FORDOS.WSA", &len); + m_wsa.reset(new Wsafile(data, len)); + tmp.reset(m_wsa->getPicture(1, palette)); + m_surf->blitFrom(tmp.get(), src, UPoint(176, 0)); - m_wsa = new Wsafile(data, len); - tmp = copySurface(m_wsa->getPicture(1, palette)); + m_surf = m_surf->getResized(2); - cp.setPosition(SPoint(176, 0)); - SDL_BlitSurface(tmp, &src, m_surf, &cp); - - m_surf = resizeSurface(m_surf, 2); - - m_rect.setPosition(SPoint(Settings::Instance()->GetWidth() / 2 - m_surf->w/2, - Settings::Instance()->GetHeight() / 4)); - - m_rect.setSize(UPoint(m_surf->w, m_surf->h)); } MainMenuState::~MainMenuState() @@ -180,7 +162,8 @@ int MainMenuState::Execute(float dt) { - Application::Instance()->Blit(m_surf, NULL, &m_rect); + m_surf.get()->blitToScreen(SPoint(Settings::Instance()->GetWidth() / 2 - m_surf->getSurface()->w/2, + Settings::Instance()->GetHeight() / 4)); return 0; } Modified: branches/dunks/src/ResMan.cpp =================================================================== --- branches/dunks/src/ResMan.cpp 2007-08-14 18:24:08 UTC (rev 131) +++ branches/dunks/src/ResMan.cpp 2007-12-08 16:04:58 UTC (rev 132) @@ -225,8 +225,7 @@ assert(p != std::string::npos); std::string fsname = std::string(name, 0, p); - filename = std::string(name, p+1, - name.length() - fsname.length() - 1); + filename = std::string(name, p+1, name.length() - fsname.length() - 1); printf("opening file from %s named %s...\n", fsname.c_str(), filename.c_str()); @@ -262,15 +261,15 @@ if (res == NULL) { - if (size != NULL) size = 0; + if (size != NULL) size = 0; return NULL; - }; - + }; + unsigned char *buf = res->readFile(filename.c_str(), size); assert(buf != NULL); - - return buf; + + return buf; } FileLike* ResMan::readFile(std::string name) Modified: branches/dunks/src/SConscript =================================================================== --- branches/dunks/src/SConscript 2007-08-14 18:24:08 UTC (rev 131) +++ branches/dunks/src/SConscript 2007-12-08 16:04:58 UTC (rev 132) @@ -18,7 +18,7 @@ "Font.cpp", "State.cpp", # "DataFile.cpp", - "PictureFactory.cpp", +# "PictureFactory.cpp", "TopLevelState.cpp", "MenuBase.cpp", "MainMenu.cpp", @@ -73,6 +73,6 @@ dunelegacy = env.Program("../dunelegacy", ["main.cpp"] + all_sources + gui_sources + pak_sources ) pakview = env.Program("../test", ["pakview.cpp"] + pakview_sources + gui_sources + pak_sources ) -#Default(dunelegacy) -Default(pakview) +Default(dunelegacy) +#Default(pakview) Modified: branches/dunks/src/gui2/Button.cpp =================================================================== --- branches/dunks/src/gui2/Button.cpp 2007-08-14 18:24:08 UTC (rev 131) +++ branches/dunks/src/gui2/Button.cpp 2007-12-08 16:04:58 UTC (rev 132) @@ -17,44 +17,39 @@ GraphicButton::GraphicButton() { - m_surfNormal = NULL; - m_surfPressed = NULL; m_pressed = false; } -GraphicButton::GraphicButton(SDL_Surface* normal, SDL_Surface* pressed) +GraphicButton::GraphicButton(ImagePtr normal, ImagePtr pressed) { setGraphics(normal, pressed); m_pressed = false; } -void GraphicButton::setGraphics(SDL_Surface* normal, SDL_Surface* pressed) +void GraphicButton::setGraphics(ImagePtr normal, ImagePtr pressed) { - assert(pressed != NULL && ((normal->w == pressed->w) && - (normal->h == pressed->h))); + assert(pressed != NULL && ((normal->getSurface()->w == pressed->getSurface()->w) && + (normal->getSurface()->h == pressed->getSurface()->h))); - m_surfNormal = normal; - m_surfPressed = pressed; + m_surfNormal.reset(normal.get()); + m_surfPressed.reset(pressed.get()); - w = normal->w; - h = normal->h; + setSize(normal->getSize()); + //w = normal->getSurfacew; + //h = normal->h; } -void GraphicButton::draw(SDL_Surface* dest, SPoint off) +void GraphicButton::draw(Image * dest, SPoint off) { if (!m_visible) return; - Rect destrect (off.x + x, off.y + y, 0, 0); - if (m_pressed) { - assert(m_surfPressed != NULL); - SDL_BlitSurface(m_surfPressed, NULL, dest, &destrect); + m_surfPressed->blitTo(dest, UPoint(off.x + x, off.y + y)); } else { - assert(m_surfNormal != NULL); - SDL_BlitSurface(m_surfNormal, NULL, dest, &destrect); + m_surfNormal->blitTo(dest, UPoint(off.x + x, off.y + y)); }; } @@ -88,8 +83,7 @@ BoringButton::~BoringButton() { - SDL_FreeSurface(m_surfNormal); - SDL_FreeSurface(m_surfPressed); + } @@ -108,82 +102,68 @@ void BoringButton::redraw() { - if (m_surfNormal != NULL) SDL_FreeSurface(m_surfNormal); - if (m_surfPressed != NULL) SDL_FreeSurface(m_surfPressed); + m_surfNormal.reset(new Image(UPoint(w,h))); + m_surfPressed.reset(new Image(UPoint(w,h))); - m_surfNormal = SDL_CreateRGBSurface(SDL_SWSURFACE, w, h, 8, - 0, 0, 0, 0); - assert(m_surfNormal != NULL); - - m_surfPressed = SDL_CreateRGBSurface(SDL_SWSURFACE, w, h, 8, - 0, 0, 0, 0); - assert(m_surfPressed != NULL); - - SDL_LockSurface(m_surfNormal); - SDL_LockSurface(m_surfPressed); - - SDL_Palette* pal = Application::Instance()->Screen()->format->palette; - - SDL_SetColors(m_surfNormal, pal->colors, 0, pal->ncolors); - SDL_SetColors(m_surfPressed, pal->colors, 0, pal->ncolors); - - SDL_FillRect(m_surfNormal, NULL, 115); - SDL_FillRect(m_surfPressed, NULL, 116); + m_surfNormal->fillRect(115); + m_surfPressed->fillRect(116); /* * Button normal */ // top lines - drawHLine(m_surfNormal, 0, 0, w-1, 229, false); - drawHLine(m_surfNormal, 0, 1, w-3, 108, false); + m_surfNormal->drawHLine(UPoint(0, 0), w-1, 229, false); + m_surfNormal->drawHLine(UPoint(0, 1), w-3, 108, false); // left lines - drawVLine(m_surfNormal, 0, 0, h-1, 229, false); - drawVLine(m_surfNormal, 1, 1, h-2, 108, false); + m_surfNormal->drawVLine(UPoint(0, 0), h-1, 229, false); + m_surfNormal->drawVLine(UPoint(1, 1), h-2, 108, false); // bottom lines - drawHLine(m_surfNormal, 1, h-2, w-2, 226, false); - drawHLine(m_surfNormal, 0, h-1, w-1, 229, false); + m_surfNormal->drawHLine(UPoint(1, h-2), w-2, 226, false); + m_surfNormal->drawHLine(UPoint(0, h-1), w-1, 229, false); // right lines - drawVLine(m_surfNormal, w-1, 0, h-1, 229, false); - drawVLine(m_surfNormal, w-2, 1, h-2, 226, false); + m_surfNormal->drawVLine(UPoint(w-1, 0), h-1, 229, false); + m_surfNormal->drawVLine(UPoint(w-2, 1), h-2, 226, false); // final pixels to make it look really duneish - putPixel(m_surfNormal, 1, h-2, 115); - putPixel(m_surfNormal, w-2, 1, 115); - putPixel(m_surfNormal, w-2, h-2, 227); + m_surfNormal->putPixel(UPoint(1, h-2), 115); + m_surfNormal->putPixel(UPoint(w-2, 1), 115); + m_surfNormal->putPixel(UPoint(w-2, h-2), 227); /* * Button pressed */ // top lines - drawHLine(m_surfPressed, 0, 0, w-1, 229, false); - drawHLine(m_surfPressed, 0, 1, w-3, 226, false); + m_surfPressed->drawHLine(UPoint(0, 0), w-1, 229, false); + m_surfPressed->drawHLine(UPoint(0, 1), w-3, 226, false); // left lines - drawVLine(m_surfPressed, 0, 0, h-1, 229, false); - drawVLine(m_surfPressed, 1, 1, h-2, 226, false); + m_surfPressed->drawVLine(UPoint(0, 0), h-1, 229, false); + m_surfPressed->drawVLine(UPoint(1, 1), h-2, 226, false); // bottom lines - drawHLine(m_surfPressed, 1, h-2, w-2, 226, false); - drawHLine(m_surfPressed, 0, h-1, w-1, 229, false); + m_surfPressed->drawHLine(UPoint(1, h-2), w-2, 226, false); + m_surfPressed->drawHLine(UPoint(0, h-1), w-1, 229, false); // right lines - drawVLine(m_surfPressed, w-1, 0, h-1, 229, false); - drawVLine(m_surfPressed, w-2, 1, h-2, 226, false); + m_surfPressed->drawVLine(UPoint(w-1, 0), h-1, 229, false); + m_surfPressed->drawVLine(UPoint(w-2, 1), h-2, 226, false); // final pixels to make it look really duneish - putPixel(m_surfPressed, 1, h-2, 227); - putPixel(m_surfPressed, w-2, 1, 227); - putPixel(m_surfPressed, w-2, h-2, 227); + m_surfPressed->putPixel(UPoint(1, h-2), 227); + m_surfPressed->putPixel(UPoint(w-2, 1), 227); + m_surfPressed->putPixel(UPoint(w-2, h-2), 227); Font* font = FontManager::Instance()->getFont("INTRO:INTRO.FNT"); Uint16 textw, texth; font->extents(m_caption.c_str(), textw, texth); + //FIXME: FontManager should be able to handle ImagePtr + font->render(m_caption.c_str(), m_surfNormal, (w / 2) - (textw / 2), ((h / 2) - (texth / 2)), 49); @@ -191,8 +171,6 @@ (w / 2) - (textw / 2), ((h / 2) - (texth / 2)), 49); - SDL_UnlockSurface(m_surfNormal); - SDL_UnlockSurface(m_surfPressed); } // ------------------------------------------------------------------ Modified: branches/dunks/src/gui2/Container.cpp =================================================================== --- branches/dunks/src/gui2/Container.cpp 2007-08-14 18:24:08 UTC (rev 131) +++ branches/dunks/src/gui2/Container.cpp 2007-12-08 16:04:58 UTC (rev 132) @@ -2,7 +2,7 @@ #include <assert.h> -void Container::draw(SDL_Surface* dest, SPoint off) +void Container::draw(Image * dest, SPoint off) { if (!m_visible) return; Modified: branches/dunks/src/gui2/Label.cpp =================================================================== --- branches/dunks/src/gui2/Label.cpp 2007-08-14 18:24:08 UTC (rev 131) +++ branches/dunks/src/gui2/Label.cpp 2007-12-08 16:04:58 UTC (rev 132) @@ -15,23 +15,13 @@ font->extents(m_caption.c_str(), textw, texth); /*If surface width was not %4 == 0 then you'd get a text in italics */ - m_surface = SDL_CreateRGBSurface(SDL_SWSURFACE, textw + 4-(textw%4) , texth, 8, - 0, 0, 0, 0); + m_surface.reset(new Image(UPoint(textw + 4-(textw%4) , texth))); - assert(m_surface != NULL); + m_surface->fillRect(bgcolour); - SDL_LockSurface(m_surface); - - SDL_Palette* pal = Application::Instance()->Screen()->format->palette; - - SDL_SetColors(m_surface, pal->colors, 0, pal->ncolors); - - SDL_FillRect(m_surface, NULL, bgcolour); - font->render(m_caption.c_str(), m_surface, - m_surface->w/2 - textw/2, - m_surface->h/2 - texth/2, 49); - SDL_UnlockSurface(m_surface); + m_surface->getSurface()->w/2 - textw/2, + m_surface->getSurface()->h/2 - texth/2, 49); // Is it needed in case of label. It's not clickable or anything. // Widget::setSize(SPoint(textw, texth)); @@ -42,13 +32,10 @@ }; -void Label::draw(SDL_Surface* dest, SPoint off) +void Label::draw(Image * dest, SPoint off) { if (!m_visible) return; - Rect destrect (off.x + x, off.y + y, 0, 0); + m_surface->blitTo(dest, UPoint(off.x + x, off.y + y)); - assert(m_surface != NULL); - SDL_BlitSurface(m_surface, NULL, dest, &destrect); - } Modified: branches/dunks/src/pakfile/Cpsfile.cpp =================================================================== --- branches/dunks/src/pakfile/Cpsfile.cpp 2007-08-14 18:24:08 UTC (rev 131) +++ branches/dunks/src/pakfile/Cpsfile.cpp 2007-12-08 16:04:58 UTC (rev 132) @@ -50,7 +50,7 @@ } - SDL_Palette* palette = Application::Instance()->Screen()->format->palette; + SDL_Palette* palette = Application::Instance()->Screen()->getSurface()->format->palette; SDL_SetColors(pic, palette->colors, 0, palette->ncolors); SDL_LockSurface(pic); Modified: branches/dunks/src/pakfile/Icnfile.cpp =================================================================== --- branches/dunks/src/pakfile/Icnfile.cpp 2007-08-14 18:24:08 UTC (rev 131) +++ branches/dunks/src/pakfile/Icnfile.cpp 2007-12-08 16:04:58 UTC (rev 132) @@ -153,7 +153,7 @@ } SDL_Surface* Icnfile::getPicture(Uint32 IndexOfFile) { - SDL_Palette* palette = Application::Instance()->Screen()->format->palette; + SDL_Palette* palette = Application::Instance()->Screen()->getSurface()->format->palette; SDL_Surface * pic; if(IndexOfFile >= NumFiles) { @@ -201,7 +201,7 @@ } SDL_Surface* Icnfile::getPictureArray(Uint32 MapfileIndex, int tilesX, int tilesY, int tilesN) { - SDL_Palette* palette = Application::Instance()->Screen()->format->palette; + SDL_Palette* palette = Application::Instance()->Screen()->getSurface()->format->palette; SDL_Surface * pic; if(MapfileIndex >= NumTilesets) { @@ -316,7 +316,7 @@ } SDL_Surface* Icnfile::getPictureRow(Uint32 StartIndex, Uint32 EndIndex) { - SDL_Palette* palette = Application::Instance()->Screen()->format->palette; + SDL_Palette* palette = Application::Instance()->Screen()->getSurface()->format->palette; SDL_Surface * pic; if((StartIndex >= NumFiles)||(EndIndex >= NumFiles)||(StartIndex > EndIndex)) { Modified: branches/dunks/src/pakfile/Shpfile.cpp =================================================================== --- branches/dunks/src/pakfile/Shpfile.cpp 2007-08-14 18:24:08 UTC (rev 131) +++ branches/dunks/src/pakfile/Shpfile.cpp 2007-12-08 16:04:58 UTC (rev 132) @@ -24,7 +24,7 @@ SDL_Surface *Shpfile::getPicture(Uint32 IndexOfFile) { - SDL_Palette *palette = Application::Instance()->Screen()->format->palette; + SDL_Palette *palette = Application::Instance()->Screen()->getSurface()->format->palette; SDL_Surface *pic = NULL; unsigned char *DecodeDestination = NULL; unsigned char *ImageOut = NULL; @@ -135,7 +135,7 @@ } SDL_Surface* Shpfile::getPictureArray(unsigned int tilesX, unsigned int tilesY, ...) { - SDL_Palette *palette = Application::Instance()->Screen()->format->palette; + SDL_Palette *palette = Application::Instance()->Screen()->getSurface()->format->palette; SDL_Surface *pic = NULL; unsigned char *DecodeDestination = NULL; unsigned char *ImageOut = NULL; Modified: branches/dunks/src/pakfile/Wsafile.cpp =================================================================== --- branches/dunks/src/pakfile/Wsafile.cpp 2007-08-14 18:24:08 UTC (rev 131) +++ branches/dunks/src/pakfile/Wsafile.cpp 2007-12-08 16:04:58 UTC (rev 132) @@ -1,3 +1,4 @@ +#include "Gfx.h" #include "pakfile/Wsafile.h" #include <SDL_endian.h> #include <stdlib.h> @@ -17,7 +18,8 @@ } NumFrames = SDL_SwapLE16(*((Uint16*) Filedata) ); - printf("numframes = %d\n", NumFrames); + printf("numframes = %d\n", NumFrames); + SizeX = SDL_SwapLE16(*((Uint16*) (Filedata + 2)) ); SizeY = SDL_SwapLE16(*((Uint16*) (Filedata + 4)) ); printf("size %d x %d\n", SizeX, SizeY); @@ -25,16 +27,18 @@ if( ((unsigned short *) Filedata)[4] == 0) { Index = (Uint32 *) (Filedata + 10); FramesPer1024ms = SDL_SwapLE32( *((Uint32*) (Filedata+6)) ); - } else { + } + else + { Index = (Uint32 *) (Filedata + 8); FramesPer1024ms = SDL_SwapLE16( *((Uint16*) (Filedata+6)) ); } - // surely /1000.0f not 100?! - fps = (FramesPer1024ms / 1024.0f) / 100.0f; + // surely /1000.0f not 100?! + fps = (FramesPer1024ms / 1024.0f) / 100.0f; - printf("FramesPer1024ms = %d\n", FramesPer1024ms); - printf("FPS = %.3f\n", fps); + printf("FramesPer1024ms = %d\n", FramesPer1024ms); + printf("FPS = %.3f\n", fps); if(Index[0] == 0) { Index++; @@ -51,10 +55,10 @@ exit(EXIT_FAILURE); } - if (lastframe != NULL) - { - memcpy(decodedFrames, lastframe->pixels, SizeX*SizeY); - }; + if (lastframe != NULL) + { + memcpy(decodedFrames, lastframe->pixels, SizeX*SizeY); + } decodeFrames(); } @@ -64,17 +68,18 @@ free(decodedFrames); } -SDL_Surface * Wsafile::getPicture(Uint32 FrameNumber, SDL_Palette *palette) +Image * Wsafile::getPicture(Uint32 FrameNumber, SDL_Palette *palette) { if(FrameNumber >= NumFrames) { return NULL; } SDL_Surface * pic; - unsigned char * Image = decodedFrames + (FrameNumber * SizeX * SizeY); + unsigned char * Frame = decodedFrames + (FrameNumber * SizeX * SizeY); // create new picture surface - if((pic = SDL_CreateRGBSurface(SDL_SWSURFACE,SizeX,SizeY,8,0,0,0,0))== NULL) { + if((pic = SDL_CreateRGBSurface(SDL_SWSURFACE,SizeX,SizeY,8,0,0,0,0))== NULL) + { return NULL; } @@ -92,13 +97,16 @@ //printf("%u\n", Image[0]); //Now we can copy line by line - for(int y = 0; y < SizeY;y++) { - memcpy( ((unsigned char*) (pic->pixels)) + y * pic->pitch , Image + y * SizeX, SizeX); + for(int y = 0; y < SizeY;y++) + { + memcpy( ((unsigned char*) (pic->pixels)) + y * pic->pitch , Frame + y * SizeX, SizeX); } SDL_UnlockSurface(pic); - return pic; + Image * img = new Image(pic); + + return img; } @@ -106,8 +114,10 @@ { unsigned char *dec80; - for(int i=0;i<NumFrames;i++) { - if( (dec80 = (unsigned char*) calloc(1,SizeX*SizeY*2)) == NULL) { + for(int i=0;i<NumFrames;i++) + { + if( (dec80 = (unsigned char*) calloc(1,SizeX*SizeY*2)) == NULL) + { fprintf(stderr, "Error: Unable to allocate memory for decoded WSA-Frames!\n"); exit(EXIT_FAILURE); } Modified: branches/dunks/src/pakview.cpp =================================================================== --- branches/dunks/src/pakview.cpp 2007-08-14 18:24:08 UTC (rev 131) +++ branches/dunks/src/pakview.cpp 2007-12-08 16:04:58 UTC (rev 132) @@ -26,7 +26,7 @@ public: PakViewState() { - img = 0; + img = ObjImg_Terrain; house = HOUSE_ATREIDES; m_button = new BoringButton("Click me, bitte!"); m_button->setSize(SPoint(160, 50)); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <shu...@us...> - 2007-08-14 18:24:13
|
Revision: 131 http://dunelegacy.svn.sourceforge.net/dunelegacy/?rev=131&view=rev Author: shutdownrunner Date: 2007-08-14 11:24:08 -0700 (Tue, 14 Aug 2007) Log Message: ----------- * Forgot to send these. Sorry Modified Paths: -------------- branches/dunks/SConstruct branches/dunks/include/Application.h branches/dunks/include/Log.h branches/dunks/include/pakfile/Icnfile.h branches/dunks/include/pakfile/Shpfile.h Added Paths: ----------- branches/dunks/include/DataCache.h branches/dunks/include/pakview.h Modified: branches/dunks/SConstruct =================================================================== --- branches/dunks/SConstruct 2007-08-14 18:21:25 UTC (rev 130) +++ branches/dunks/SConstruct 2007-08-14 18:24:08 UTC (rev 131) @@ -43,9 +43,12 @@ "SDL_ttf", ]) + +# If boost fails for you make sure you remove -mt from lines 49 and 50 +# It's a debian fix. if sys.platform != 'win32': - env.Append(LIBS=[ "boost_signals", - "boost_filesystem", + env.Append(LIBS=[ "boost_signals-mt", + "boost_filesystem-mt", ]) env.Append(CPPPATH = [ "${SDL_INCLUDE_PATH}", Modified: branches/dunks/include/Application.h =================================================================== --- branches/dunks/include/Application.h 2007-08-14 18:21:25 UTC (rev 130) +++ branches/dunks/include/Application.h 2007-08-14 18:24:08 UTC (rev 131) @@ -6,6 +6,8 @@ #include "SDL.h" #include "gui2/Container.h" +#include "State.h" +#include "TopLevelState.h" typedef enum { CURSOR_NORMAL, @@ -54,7 +56,7 @@ void UpdateVideoMode(bool fullscreen); void UpdateVideoMode(Uint16 w, Uint16 h); void UpdateVideoMode(Uint16 w, Uint16 h, bool fullscreen); - + private: void InitSettings(); void InitAudio(); Added: branches/dunks/include/DataCache.h =================================================================== --- branches/dunks/include/DataCache.h (rev 0) +++ branches/dunks/include/DataCache.h 2007-08-14 18:24:08 UTC (rev 131) @@ -0,0 +1,112 @@ +#ifndef DUNE_DATACACHE_H +#define DUNE_DATACACHE_H + +#include "Application.h" +#include "Gfx.h" +#include "Settings.h" +#include "ResMan.h" +#include "singleton.h" + +#include "pakfile/Cpsfile.h" +#include "pakfile/Icnfile.h" +#include "pakfile/Palette.h" +#include "pakfile/Shpfile.h" +#include "pakfile/Wsafile.h" + +#include "houses.h" + +#include <map> +#include <vector> + +typedef enum { + ObjImg_Tank_Base, + ObjImg_Tank_Gun, + ObjImg_Siegetank_Base, + ObjImg_Siegetank_Gun, + ObjImg_Devastator_Base, + ObjImg_Devastator_Gun, + ObjImg_Sonictank_Gun, + ObjImg_Launcher_Gun, + ObjImg_Quad, + ObjImg_Trike, + ObjImg_Harvester, + ObjImg_Harvester_Sand, + ObjImg_MCV, + ObjImg_Carryall, + ObjImg_Frigate, + ObjImg_Ornithopter, + ObjImg_Trooper, + ObjImg_Infantry, + ObjImg_Saboteur, + ObjImg_Sandworm, + ObjImg_ConstructionYard, + ObjImg_Windtrap, + ObjImg_Refinery, + ObjImg_Barracks, + ObjImg_WOR, + ObjImg_Radar, + ObjImg_LightFactory, + ObjImg_Silo, + ObjImg_HeavyFactory, + ObjImg_HighTechFactory, + ObjImg_IX, + ObjImg_Palace, + ObjImg_RepairYard, + ObjImg_Starport, + ObjImg_GunTurret, + ObjImg_RocketTurret, + ObjImg_Wall, + ObjImg_Bullet_SmallRocket, + ObjImg_Bullet_MediumRocket, + ObjImg_Bullet_LargeRocket, + ObjImg_Bullet_Small, + ObjImg_Bullet_Medium, + ObjImg_Bullet_Sonic, + ObjImg_Hit_Gas, + ObjImg_Hit_Shell, + ObjImg_ExplosionSmall, + ObjImg_ExplosionMedium1, + ObjImg_ExplosionMedium2, + ObjImg_ExplosionLarge1, + ObjImg_ExplosionLarge2, + ObjImg_ExplosionSmallUnit, + ObjImg_DeadInfantry, + ObjImg_Smoke, + ObjImg_SandwormShimmerMask, + ObjImg_Terrain, + ObjImg_RockDamage, + ObjImg_SandDamage, + ObjImg_Terrain_Hidden, + NUM_OBJIMGS +} ObjImg_enum; + +#define GROUNDUNIT_ROW(i) (i+2)|TILE_NORMAL,(i+1)|TILE_NORMAL,i|TILE_NORMAL,(i+1)|TILE_FLIPV,(i+2)|TILE_FLIPV,(i+3)|TILE_FLIPV, (i+4)|TILE_NORMAL,(i+3)|TILE_NORMAL +#define AIRUNIT_ROW(i) (i+2)|TILE_NORMAL,(i+1)|TILE_NORMAL,i|TILE_NORMAL,(i+1)|TILE_FLIPV,(i+2)|TILE_FLIPV,(i+1)|TILE_ROTATE, i|TILE_FLIPH,(i+1)|TILE_FLIPH +#define ORNITHOPTER_ROW(i) (i+6)|TILE_NORMAL,(i+3)|TILE_NORMAL,i|TILE_NORMAL,(i+3)|TILE_FLIPV,(i+6)|TILE_FLIPV,(i+3)|TILE_ROTATE, i|TILE_FLIPH,(i+3)|TILE_FLIPH +#define INFANTRY_ROW(i) (i+3)|TILE_NORMAL,i|TILE_NORMAL,(i+3)|TILE_FLIPV,(i+6)|TILE_NORMAL +#define HARVESTERSAND_ROW(i) (i+6)|TILE_NORMAL,(i+3)|TILE_NORMAL,i|TILE_NORMAL,(i+3)|TILE_FLIPV,(i+6)|TILE_FLIPV,(i+9)|TILE_FLIPV,(i+12)|TILE_NORMAL,(i+9)|TILE_NORMAL +#define ROCKET_ROW(i) (i+4)|TILE_NORMAL,(i+3)|TILE_NORMAL,(i+2)|TILE_NORMAL,(i+1)|TILE_NORMAL,i|TILE_NORMAL,(i+1)|TILE_FLIPV,(i+2)|TILE_FLIPV,(i+3)|TILE_FLIPV, \ + (i+4)|TILE_FLIPV,(i+3)|TILE_ROTATE,(i+2)|TILE_ROTATE, (i+1)|TILE_ROTATE,i|TILE_FLIPH,(i+1)|TILE_FLIPH,(i+2)|TILE_FLIPH,(i+3)|TILE_FLIPH + + +typedef std::map <unsigned, ImagePtr> images; +typedef std::vector <images*> remapped_images; //One for each house + +class DataCache : public Singleton<DataCache> +{ + friend class Singleton<DataCache>; + + protected: + DataCache(); + ~DataCache(); + + public: + void addObjImg(unsigned ID, SDL_Surface * tmp); + ImagePtr getObjImg(unsigned ID, unsigned house = HOUSE_HARKONNEN); + private: + bool addObjImg(unsigned ID) { return false;}; + remapped_images m_objImg; + remapped_images m_guiImg; +}; + +#endif // DUNE_DATACACHE_H Modified: branches/dunks/include/Log.h =================================================================== --- branches/dunks/include/Log.h 2007-08-14 18:21:25 UTC (rev 130) +++ branches/dunks/include/Log.h 2007-08-14 18:24:08 UTC (rev 131) @@ -198,7 +198,7 @@ int indentLevel; bool checkMessageVerbosity(ConstString logSystem, LogVerbosity verbosity); - void doLog(ConstString logSystem, LogVerbosity verbosity, const char *format, ...); + void doLog(ConstString logSystem, LogVerbosity verbosity, const char *format, va_list args); }; Modified: branches/dunks/include/pakfile/Icnfile.h =================================================================== --- branches/dunks/include/pakfile/Icnfile.h 2007-08-14 18:21:25 UTC (rev 130) +++ branches/dunks/include/pakfile/Icnfile.h 2007-08-14 18:24:08 UTC (rev 131) @@ -3,16 +3,82 @@ #include "SDL.h" +/*! + A class for loading a *.ICN-File and the corresponding *.MAP-File. + + This class can read icn-Files and return the contained pictures as a SDL_Surface. An icn-File contains + small 16x16 pixel tiles. The map-file contains the information how to build up a complete picture with + this small tiles. +*/ class Icnfile { +private: + //! Internal structure for the MAP-File. + struct MapfileEntry + { + Uint32 NumTiles; + Uint16* TileIndex; + }; public: - Icnfile(unsigned char * bufFiledata, int bufsize); + Icnfile(unsigned char * bufFiledata, int bufsize, + unsigned char * bufMapdata, int mapsize); ~Icnfile(); - SDL_Surface * getPicture(Uint32 IndexOfFile, SDL_Palette *palette); + SDL_Surface * getPicture(Uint32 IndexOfFile); +/// Returns an array of pictures in the icn-File +/*! + This method returns a SDL_Surface containing multiple tiles/pictures. Which tiles to include is specified by MapfileIndex. The + MapfileIndex specifies the tileset. One tileset constists of multiple tiles of the icn-File. + The last 3 parameters specify how to arrange the tiles: + - If all 3 parameters are 0 then a "random" layout is choosen, which should look good. + - If tilesX and tilesY is set to non-zero values then the result surface contains tilesX*tilesY tiles and this tilesN-times side by side. + - If all there parameters are non-zero then the result surface is exactly in this arrangement. + + tilesX*tilesY*tilesN must always the number of tiles in this tileset. Otherwise NULL is returned.<br><br> + Example: + @code + Tileset = 10,11,12,13,14,15,16,17,18,19,20,21 + tilesX = 2; tilesY = 2; tilesN = 3 + + returned picture: + 10 11 14 15 18 19 + 12 13 16 17 20 21 + @endcode + <br> + The returned SDL_Surface should be freed with SDL_FreeSurface() if no longer needed. + @param MapfileIndex specifies which tileset to use (zero based) + @param tilesX how many tiles in x direction + @param tilesY how many tiles in y direction + @param tilesN how many tilesX*tilesY blocks in a row + @return the result surface with tilesX*tilesY*tilesN tiles +*/ + SDL_Surface * getPictureArray(Uint32 MapfileIndex, int tilesX = 0, int tilesY = 0, int tilesN = 0); + +/*! + This method returns a SDL_Surface containing multiple tiles/pictures. The returned surface contains all + tiles from StartIndex to EndIndex. + The returned SDL_Surface should be freed with SDL_FreeSurface() if no longer needed. + @param StartIndex The first tile to use + @param EndIndex The last tile to use + @return the result surface with (EndIndex-StartIndex+1) tiles. NULL on errors. +*/ + SDL_Surface * getPictureRow(Uint32 StartIndex, Uint32 EndIndex); + + /// Returns the number of tiles +/*! + Returns the number of tiles in the icn-File. + @return Number of tiles +*/ int getNumFiles(); + + /// Returns the number of tilesets +/*! + Returns the number of tilesets in the map-File. + @return Number of tilesets +*/ + int getNumTilesets() { return NumTilesets; }; private: unsigned char* Filedata; @@ -20,6 +86,9 @@ Uint32 NumFiles; + Uint16 NumTilesets; + MapfileEntry* Tileset; + unsigned char* SSET; Uint32 SSET_Length; unsigned char* RPAL; Modified: branches/dunks/include/pakfile/Shpfile.h =================================================================== --- branches/dunks/include/pakfile/Shpfile.h 2007-08-14 18:21:25 UTC (rev 130) +++ branches/dunks/include/pakfile/Shpfile.h 2007-08-14 18:24:08 UTC (rev 131) @@ -4,6 +4,14 @@ #include "SDL.h" #include "pakfile/Decode.h" +#define TILE_NORMAL 0x00010000 +#define TILE_FLIPH 0x00100000 +#define TILE_FLIPV 0x01000000 +#define TILE_ROTATE 0x10000000 + +#define TILE_GETINDEX(x) (x & 0x0000FFFF) +#define TILE_GETTYPE(x) (x & 0xFFFF0000) + struct ShpfileEntry { Uint32 StartOffset; @@ -16,8 +24,38 @@ Shpfile(unsigned char * bufFiledata, int bufsize); ~Shpfile(); - SDL_Surface* getPicture(Uint32 IndexOfFile, SDL_Palette *palette); +/*! + This method returns a SDL_Surface containing the nth picture in this shp-File. + The returned SDL_Surface should be freed with SDL_FreeSurface() if no longer needed. + @param IndexOfFile specifies which picture to return (zero based) + @return nth picture in this shp-File +*/ + SDL_Surface* getPicture(Uint32 IndexOfFile); +/*! + This method returns a SDL_Surface containing an array of pictures from this shp-File. + All pictures must be of the same size. tilesX/tilesY specifies how many pictures are in this row/column. + Afterwards there must be tilesX*tilesY many parameters. Every parameter specifies which picture + of this shp-File should be used. This indices must be ORed with a parameter specifing hwo they should + be in the result surface. There are 4 modes and you must OR exactly one: + - TILE_NORMAL Normal + - TILE_FLIPH mirrored horizontally + - TILE_FLIPV mirrored vertically + - TILE_ROTATE Rotated by 180 degress + + Example: + @code + picture = myShpfile->getPictureArray(4,1, TILE_NORMAL | 20, TILE_FLIPH | 23, TILE_ROTATE | 67, TILE_NORMAL | 68); + @endcode + This example would create a surface with four pictures in it. From the left to the right there are + picture 20,23,67 and 68. picture 23 is mirrored horizontally, 67 is rotated.<br><br> + The returned SDL_Surface should be freed with SDL_FreeSurface() if no longer needed. + @param tilesX how many pictures in one row + @param tilesY how many pictures in one column + @return picture in this shp-File containing all specified pictures +*/ + SDL_Surface* getPictureArray(unsigned int tilesX, unsigned int tilesY, ...); + inline int getNumFiles() {return (int) NumFiles;}; private: Added: branches/dunks/include/pakview.h =================================================================== --- branches/dunks/include/pakview.h (rev 0) +++ branches/dunks/include/pakview.h 2007-08-14 18:24:08 UTC (rev 131) @@ -0,0 +1,6 @@ +#ifndef DUNE_PAKVIEW_H +#define DUNE_PAKVIEW_H + + + +#endif // DUNE_PAKVIEW_H This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <shu...@us...> - 2007-08-14 18:21:33
|
Revision: 130 http://dunelegacy.svn.sourceforge.net/dunelegacy/?rev=130&view=rev Author: shutdownrunner Date: 2007-08-14 11:21:25 -0700 (Tue, 14 Aug 2007) Log Message: ----------- * One commit, once a year:) * Make sure you have .PAK in paks dir * Run ./test instead of ./dunelegacy * Reverted Log.cpp, Log.h so it probably won't compile on 64bit computer. Just for a moment hopefuly * Don't expect too much Modified Paths: -------------- branches/dunks/src/Application.cpp branches/dunks/src/Log.cpp branches/dunks/src/SConscript branches/dunks/src/pakfile/Icnfile.cpp branches/dunks/src/pakfile/Shpfile.cpp branches/dunks/src/pakview.cpp Added Paths: ----------- branches/dunks/src/DataCache.cpp Modified: branches/dunks/src/Application.cpp =================================================================== --- branches/dunks/src/Application.cpp 2007-01-29 12:27:15 UTC (rev 129) +++ branches/dunks/src/Application.cpp 2007-08-14 18:21:25 UTC (rev 130) @@ -26,9 +26,12 @@ #include "pakfile/Palette.h" #include "pakfile/Shpfile.h" +#include "pakfile/Cpsfile.h" #include "ResMan.h" +#include "houses.h" + #define VERSION "0.94.1" Uint8 gpaloff; @@ -111,15 +114,13 @@ m_rootWidget = new Container(); - //get the house palettes - /* + houseColour[HOUSE_ATREIDES] = COLOUR_ATREIDES; houseColour[HOUSE_ORDOS] = COLOUR_ORDOS; houseColour[HOUSE_HARKONNEN] = COLOUR_HARKONNEN; houseColour[HOUSE_SARDAUKAR] = COLOUR_SARDAUKAR; houseColour[HOUSE_FREMEN] = COLOUR_FREMEN; houseColour[HOUSE_MERCENARY] = COLOUR_MERCENARY; - */ //printf("loading mentat.....\n"); //MentatClass* m = new MentatClass(); @@ -204,6 +205,12 @@ SDL_Palette * pal = tmp.getPalette(); + //This fixes white wheels. Is palette broken or sth?? + + pal->colors[205].r = 109; + pal->colors[205].g = 109; + pal->colors[205].b = 153; + assert(pal != NULL); printf("setting palette %d colors\n", pal->ncolors); assert( SDL_SetColors(m_screen, pal->colors, 0, pal->ncolors) == 1 ); @@ -292,8 +299,9 @@ Shpfile mouse (data, len); - m_cursor = mouse.getPicture(0, m_screen->format->palette); + m_cursor = mouse.getPicture(0); + /* fprintf(stdout, "starting sound...\n"); soundPlayer = new SoundPlayerClass(); @@ -360,7 +368,7 @@ fnt->render("abcdefghijklmnopqrstuvwxz", m_screen, 10, 30, gpaloff); #endif -#if 1 +#if 0 SDL_Rect pdest = {10, 10, 5, 10}; for (Uint32 i=0; i!=256; i++) @@ -369,7 +377,7 @@ SDL_FillRect(m_screen, &pdest, i); } #endif - + SDL_Flip(m_screen); fps_frames ++; @@ -407,6 +415,7 @@ m_rootWidget->handleMotion(SPoint(event.motion.x, event.motion.y)); break; case SDL_MOUSEBUTTONDOWN: + gpaloff++; m_rootWidget->handleButtonDown( event.button.button, SPoint(event.button.x, event.button.y)); break; Added: branches/dunks/src/DataCache.cpp =================================================================== --- branches/dunks/src/DataCache.cpp (rev 0) +++ branches/dunks/src/DataCache.cpp 2007-08-14 18:21:25 UTC (rev 130) @@ -0,0 +1,125 @@ +#include "DataCache.h" + + +using namespace std; + +DataCache::DataCache() { + for (int i=0; i< NUM_HOUSES; i++) + { + m_objImg.push_back(new images()); + } + + int len; + unsigned char * data; + + Icnfile* icon; + Shpfile* units; + Shpfile* units1; + Shpfile* units2; + + //LOADING FILES + data = ResMan::Instance()->readFile("DUNE:UNITS.SHP", &len); + units = new Shpfile(data, len); + + data = ResMan::Instance()->readFile("DUNE:UNITS1.SHP", &len); + units1 = new Shpfile(data, len); + + data = ResMan::Instance()->readFile("DUNE:UNITS2.SHP", &len); + units2 = new Shpfile(data, len); + + + int maplen; + unsigned char * mapdata; + + data = ResMan::Instance()->readFile("DUNE:ICON.ICN", &len); + mapdata = ResMan::Instance()->readFile("DUNE:ICON.MAP", &maplen); + icon = new Icnfile(data, len, mapdata, maplen); + + + //UNITS, BUILDINGS, EXPLOSIONS, and everything that's on the map + addObjImg(ObjImg_Tank_Base, units2->getPictureArray(8,1,GROUNDUNIT_ROW(0))); + addObjImg(ObjImg_Tank_Gun, units2->getPictureArray(8,1,GROUNDUNIT_ROW(5))); + addObjImg(ObjImg_Siegetank_Base, units2->getPictureArray(8,1,GROUNDUNIT_ROW(10))); + addObjImg(ObjImg_Siegetank_Gun, units2->getPictureArray(8,1,GROUNDUNIT_ROW(15))); + addObjImg(ObjImg_Devastator_Base, units2->getPictureArray(8,1,GROUNDUNIT_ROW(20))); + addObjImg(ObjImg_Devastator_Gun, units2->getPictureArray(8,1,GROUNDUNIT_ROW(25))); + addObjImg(ObjImg_Sonictank_Gun, units2->getPictureArray(8,1,GROUNDUNIT_ROW(30))); + addObjImg(ObjImg_Launcher_Gun, units2->getPictureArray(8,1,GROUNDUNIT_ROW(35))); + addObjImg(ObjImg_Quad, units->getPictureArray(8,1,GROUNDUNIT_ROW(0))); + addObjImg(ObjImg_Trike, units->getPictureArray(8,1,GROUNDUNIT_ROW(5))); + addObjImg(ObjImg_Harvester, units->getPictureArray(8,1,GROUNDUNIT_ROW(10))); + addObjImg(ObjImg_Harvester_Sand, units1->getPictureArray(8,3,HARVESTERSAND_ROW(72),HARVESTERSAND_ROW(73),HARVESTERSAND_ROW(74))); + addObjImg(ObjImg_MCV, units->getPictureArray(8,1,GROUNDUNIT_ROW(15))); + addObjImg(ObjImg_Carryall, units->getPictureArray(8,2,AIRUNIT_ROW(45),AIRUNIT_ROW(48))); + addObjImg(ObjImg_Frigate, units->getPictureArray(8,1,AIRUNIT_ROW(60))); + addObjImg(ObjImg_Ornithopter, units->getPictureArray(8,3,ORNITHOPTER_ROW(51),ORNITHOPTER_ROW(52),ORNITHOPTER_ROW(53))); + addObjImg(ObjImg_Trooper, units->getPictureArray(4,3,INFANTRY_ROW(82),INFANTRY_ROW(83),INFANTRY_ROW(84))); + addObjImg(ObjImg_Infantry, units->getPictureArray(4,3,INFANTRY_ROW(73),INFANTRY_ROW(74),INFANTRY_ROW(75))); + addObjImg(ObjImg_Saboteur, units->getPictureArray(4,3,INFANTRY_ROW(63),INFANTRY_ROW(64),INFANTRY_ROW(65))); + addObjImg(ObjImg_Sandworm, units1->getPictureArray(1,5,67|TILE_NORMAL,68|TILE_NORMAL,69|TILE_NORMAL,70|TILE_NORMAL,71|TILE_NORMAL)); + addObjImg(ObjImg_ConstructionYard, icon->getPictureArray(17)); + addObjImg(ObjImg_Windtrap, icon->getPictureArray(19)); + addObjImg(ObjImg_Refinery, icon->getPictureArray(21)); + addObjImg(ObjImg_Barracks, icon->getPictureArray(18)); + addObjImg(ObjImg_WOR, icon->getPictureArray(16)); + addObjImg(ObjImg_Radar, icon->getPictureArray(26)); + addObjImg(ObjImg_LightFactory, icon->getPictureArray(12)); + addObjImg(ObjImg_Silo, icon->getPictureArray(25)); + addObjImg(ObjImg_HeavyFactory, icon->getPictureArray(13)); + addObjImg(ObjImg_HighTechFactory, icon->getPictureArray(14)); + addObjImg(ObjImg_IX, icon->getPictureArray(15)); + addObjImg(ObjImg_Palace, icon->getPictureArray(11)); + addObjImg(ObjImg_RepairYard, icon->getPictureArray(22)); + addObjImg(ObjImg_Starport, icon->getPictureArray(20)); + addObjImg(ObjImg_GunTurret, icon->getPictureArray(23)); + addObjImg(ObjImg_RocketTurret, icon->getPictureArray(24)); + addObjImg(ObjImg_Wall, icon->getPictureArray(6,1,1,75)); + addObjImg(ObjImg_Bullet_SmallRocket, units->getPictureArray(16,1,ROCKET_ROW(35))); + addObjImg(ObjImg_Bullet_MediumRocket, units->getPictureArray(16,1,ROCKET_ROW(20))); + addObjImg(ObjImg_Bullet_LargeRocket, units->getPictureArray(16,1,ROCKET_ROW(40))); + addObjImg(ObjImg_Bullet_Small, units1->getPicture(23)); + addObjImg(ObjImg_Bullet_Medium, units1->getPicture(24)); + addObjImg(ObjImg_Bullet_Sonic, units1->getPicture(9)); + addObjImg(ObjImg_Hit_Gas, units1->getPictureArray(5,1,57|TILE_NORMAL,58|TILE_NORMAL,59|TILE_NORMAL,60|TILE_NORMAL,61|TILE_NORMAL)); + addObjImg(ObjImg_Hit_Shell, units1->getPictureArray(3,1,2|TILE_NORMAL,3|TILE_NORMAL,4|TILE_NORMAL)); + addObjImg(ObjImg_ExplosionSmall, units1->getPictureArray(5,1,32|TILE_NORMAL,33|TILE_NORMAL,34|TILE_NORMAL,35|TILE_NORMAL,36|TILE_NORMAL)); + addObjImg(ObjImg_ExplosionMedium1, units1->getPictureArray(5,1,47|TILE_NORMAL,48|TILE_NORMAL,49|TILE_NORMAL,50|TILE_NORMAL,51|TILE_NORMAL)); + addObjImg(ObjImg_ExplosionMedium2, units1->getPictureArray(5,1,52|TILE_NORMAL,53|TILE_NORMAL,54|TILE_NORMAL,55|TILE_NORMAL,56|TILE_NORMAL)); + addObjImg(ObjImg_ExplosionLarge1, units1->getPictureArray(5,1,37|TILE_NORMAL,38|TILE_NORMAL,39|TILE_NORMAL,40|TILE_NORMAL,41|TILE_NORMAL)); + addObjImg(ObjImg_ExplosionLarge2, units1->getPictureArray(5,1,42|TILE_NORMAL,43|TILE_NORMAL,44|TILE_NORMAL,45|TILE_NORMAL,46|TILE_NORMAL)); + addObjImg(ObjImg_ExplosionSmallUnit, units1->getPictureArray(2,1,0|TILE_NORMAL,1|TILE_NORMAL)); + addObjImg(ObjImg_DeadInfantry, icon->getPictureArray(4,1,1,6)); + addObjImg(ObjImg_Smoke, units1->getPictureArray(3,1,29|TILE_NORMAL,30|TILE_NORMAL,31|TILE_NORMAL)); + addObjImg(ObjImg_SandwormShimmerMask, units1->getPicture(10)); + addObjImg(ObjImg_Terrain, icon->getPictureRow(124,209)); + addObjImg(ObjImg_RockDamage, icon->getPictureRow(1,6)); + addObjImg(ObjImg_SandDamage, units1->getPictureArray(3,1,5|TILE_NORMAL,6|TILE_NORMAL,7|TILE_NORMAL)); + addObjImg(ObjImg_Terrain_Hidden, icon->getPictureRow(108,123)); +} + +void DataCache::addObjImg(unsigned ID, SDL_Surface * tmp) { + + m_objImg[HOUSE_HARKONNEN]->insert(pair<unsigned, ImagePtr>(ID, + ImagePtr(new Image(tmp)))); +} + +ImagePtr DataCache::getObjImg(unsigned ID, unsigned house) { + + images::iterator iter = m_objImg[house]->find(ID); + if (iter != m_objImg[house]->end()) + { + return m_objImg[house]->find(ID)->second; + } + else + { + ImagePtr source = m_objImg[HOUSE_HARKONNEN]->find(ID)->second; + ImagePtr copy = source->getRecoloredByHouse(house); + m_objImg[HOUSE_HARKONNEN]->insert(pair<unsigned, ImagePtr>(ID, copy)); + return copy; + } + +} + +DataCache::~DataCache() { + +} Modified: branches/dunks/src/Log.cpp =================================================================== --- branches/dunks/src/Log.cpp 2007-01-29 12:27:15 UTC (rev 129) +++ branches/dunks/src/Log.cpp 2007-08-14 18:21:25 UTC (rev 130) @@ -138,9 +138,9 @@ return true; } -void Log::doLog(ConstString logSystem, LogVerbosity verbosity, const char *format, ...) +void Log::doLog(ConstString logSystem, LogVerbosity verbosity, const char *format, va_list args) { - va_list args ; + static char message[LOG_MAX_STRING_LENGTH]; static char formated[LOG_MAX_STRING_LENGTH]; const char *verb; Modified: branches/dunks/src/SConscript =================================================================== --- branches/dunks/src/SConscript 2007-01-29 12:27:15 UTC (rev 129) +++ branches/dunks/src/SConscript 2007-08-14 18:21:25 UTC (rev 130) @@ -18,7 +18,7 @@ "Font.cpp", "State.cpp", # "DataFile.cpp", - + "PictureFactory.cpp", "TopLevelState.cpp", "MenuBase.cpp", "MainMenu.cpp", @@ -52,13 +52,27 @@ "pakfile/Palette.cpp", ] +pakview_sources = [ "Application.cpp", + "ConfigFile.cpp", + "DataCache.cpp", + "Font.cpp", + "Gfx.cpp", + "houses.cpp", + "Log.cpp", + "ResMan.cpp", + "Settings.cpp", + "Strings.cpp", + "State.cpp", + "TopLevelState.cpp", + ] + #gamelib = env.StaticLibrary("dune_game", all_sources) #guilib = env.StaticLibrary("dune_gui", gui_sources + gamelib) #paklib = env.StaticLibrary("dune_pak", pak_sources) dunelegacy = env.Program("../dunelegacy", ["main.cpp"] + all_sources + gui_sources + pak_sources ) -#pakview = env.Program("../pakview", ["pakview.cpp", gamelib, guilib, paklib] ) +pakview = env.Program("../test", ["pakview.cpp"] + pakview_sources + gui_sources + pak_sources ) -Default(dunelegacy) -#Default(pakview) +#Default(dunelegacy) +Default(pakview) Modified: branches/dunks/src/pakfile/Icnfile.cpp =================================================================== --- branches/dunks/src/pakfile/Icnfile.cpp 2007-01-29 12:27:15 UTC (rev 129) +++ branches/dunks/src/pakfile/Icnfile.cpp 2007-08-14 18:21:25 UTC (rev 130) @@ -1,3 +1,5 @@ +#include "Application.h" + #include "pakfile/Icnfile.h" #include <SDL_endian.h> @@ -7,14 +9,66 @@ #define SIZE_X 16 #define SIZE_Y 16 -//extern SDL_Palette* palette; - + -Icnfile::Icnfile(unsigned char * bufFiledata, int bufsize) -{ +Icnfile::Icnfile(unsigned char * bufFiledata, int bufsize, + unsigned char * bufMapdata, int mapsize) { Filedata = bufFiledata; IcnFilesize = bufsize; + + int MapFilesize = mapsize; + unsigned char * MapFiledata = bufMapdata; + int i; + + // now we can start creating the Tilesetindex + if(MapFilesize < 2) { + fprintf(stderr,"Mapfile: This *.map-File is too short!\n"); + exit(EXIT_FAILURE); + } + NumTilesets = SDL_SwapLE16( *((Uint16 *) MapFiledata)); + + if(MapFilesize < NumTilesets * 2) { + fprintf(stderr,"Mapfile: This *.map-File is too short!\n"); + exit(EXIT_FAILURE); + } + + if((Tileset = (MapfileEntry*) malloc(sizeof(MapfileEntry)*NumTilesets)) == NULL) { + fprintf(stderr,"Mapfile: Allocating memory failed!\n"); + exit(EXIT_FAILURE); + } + + // calculate size for all entries + Uint16 index = SDL_SwapLE16( ((Uint16*) MapFiledata)[0]); + for(i = 1; i < NumTilesets; i++) { + Uint16 tmp = SDL_SwapLE16( ((Uint16*) MapFiledata)[i]); + Tileset[i-1].NumTiles = tmp - index; + index = tmp; + } + Tileset[NumTilesets-1].NumTiles = (MapFilesize/2) - index; + + for(i = 0; i < NumTilesets; i++) { + + if((Tileset[i].TileIndex = (Uint16*) malloc(sizeof(Uint16)*Tileset[i].NumTiles)) == NULL) { + fprintf(stderr,"Mapfile: Allocating memory failed!\n"); + exit(EXIT_FAILURE); + } + + index = SDL_SwapLE16( ((Uint16*) MapFiledata)[i]); + + if((unsigned int)MapFilesize < (index+Tileset[i].NumTiles)*2 ) { + fprintf(stderr,"Mapfile: This *.map-File is too short!\n"); + exit(EXIT_FAILURE); + } + + // now we can read in + for(unsigned int j = 0; j < Tileset[i].NumTiles; j++) { + Tileset[i].TileIndex[j] = SDL_SwapLE16( ((Uint16*) MapFiledata)[index+j]); + } + } + free(MapFiledata); + // reading MAP-File is now finished + // check if we can access first section; if(IcnFilesize < 0x20) { @@ -98,7 +152,8 @@ ; } -SDL_Surface* Icnfile::getPicture(Uint32 IndexOfFile, SDL_Palette *palette) { +SDL_Surface* Icnfile::getPicture(Uint32 IndexOfFile) { + SDL_Palette* palette = Application::Instance()->Screen()->format->palette; SDL_Surface * pic; if(IndexOfFile >= NumFiles) { @@ -145,6 +200,172 @@ return pic; } +SDL_Surface* Icnfile::getPictureArray(Uint32 MapfileIndex, int tilesX, int tilesY, int tilesN) { + SDL_Palette* palette = Application::Instance()->Screen()->format->palette; + SDL_Surface * pic; + + if(MapfileIndex >= NumTilesets) { + return NULL; + } + + if((tilesX == 0) && (tilesY == 0) && (tilesN == 0)) { + // guest what is best + int tmp = Tileset[MapfileIndex].NumTiles; + if(tmp == 24) { + // special case (radar station and light factory) + tilesX = 2; + tilesY = 2; + tilesN = 6; + } else if((tmp % 9) == 0) { + tilesX = 3; + tilesY = 3; + tilesN = tmp / 9; + } else if((tmp % 6) == 0) { + tilesX = 3; + tilesY = 2; + tilesN = tmp / 6; + } else if((tmp % 4) == 0) { + tilesX = 2; + tilesY = 2; + tilesN = tmp / 4; + } else if((tmp>=40) && ((tmp % 5) == 0)) { + tilesX = tmp/5; + tilesY = 5; + tilesN = 1; + } else { + tilesX = 1; + tilesY = 1; + tilesN = tmp; + } + + } else if( ((tilesX == 0) || (tilesY == 0)) && (tilesN == 0)) { + // not possible + return NULL; + } else if((tilesX == 0) && (tilesY == 0) && (tilesN != 0)) { + if(Tileset[MapfileIndex].NumTiles % tilesN == 0) { + // guest what is best + int tmp = Tileset[MapfileIndex].NumTiles / tilesN; + if((tmp % 3) == 0) { + tilesX = tmp/3; + tilesY = 3; + } else if((tmp % 2) == 0) { + tilesX = tmp/2; + tilesY = 2; + } else { + tilesX = tmp; + tilesY = 1; + } + } else { + // not possible + return NULL; + } + } else { + if((unsigned int)tilesX*tilesY*tilesN != Tileset[MapfileIndex].NumTiles) { + return NULL; + } + } + + // create new picture surface + if((pic = SDL_CreateRGBSurface(SDL_HWSURFACE,SIZE_X*tilesX*tilesN,SIZE_Y*tilesY,8,0,0,0,0))== NULL) { + return NULL; + } + + SDL_SetColors(pic, palette->colors, 0, palette->ncolors); + SDL_LockSurface(pic); + + int Tileidx=0; + for(int n = 0; n < tilesN; n++) { + for(int y = 0; y < tilesY; y++) { + for(int x = 0; x < tilesX; x++) { + int IndexOfFile = Tileset[MapfileIndex].TileIndex[Tileidx]; + + // check if palette is in range + if(RTBL[IndexOfFile] >= RPAL_Length / 16) { + SDL_UnlockSurface(pic); + SDL_FreeSurface(pic); + return NULL; + } + + unsigned char* palettestart = RPAL + (16 * RTBL[IndexOfFile]); + unsigned char * filestart = SSET + (IndexOfFile * ((SIZE_X * SIZE_Y)/2)); + + //Now we can copy to surface + unsigned char *dest = (unsigned char*) (pic->pixels) + (pic->pitch)*y*SIZE_Y + (x+n*tilesX) * SIZE_X; + unsigned char pixel; + for(int y = 0; y < SIZE_Y;y++) { + for(int x = 0; x < SIZE_X; x+=2) { + pixel = filestart[ (y*SIZE_X + x) / 2]; + pixel = pixel >> 4; + dest[x] = palettestart[pixel]; + + pixel = filestart[ (y*SIZE_X + x) / 2]; + pixel = pixel & 0x0F; + dest[x+1] = palettestart[pixel]; + } + dest += pic->pitch; + } + + Tileidx++; + } + } + } + + SDL_UnlockSurface(pic); + + return pic; +} + +SDL_Surface* Icnfile::getPictureRow(Uint32 StartIndex, Uint32 EndIndex) { + SDL_Palette* palette = Application::Instance()->Screen()->format->palette; + SDL_Surface * pic; + + if((StartIndex >= NumFiles)||(EndIndex >= NumFiles)||(StartIndex > EndIndex)) { + return NULL; + } + + Uint32 NumTiles = EndIndex - StartIndex + 1; + // create new picture surface + if((pic = SDL_CreateRGBSurface(SDL_HWSURFACE,SIZE_X*NumTiles,SIZE_Y,8,0,0,0,0))== NULL) { + return NULL; + } + + SDL_SetColors(pic, palette->colors, 0, palette->ncolors); + SDL_LockSurface(pic); + + for(unsigned int i = 0; i < NumTiles; i++) { + int IndexOfFile = i+StartIndex; + + // check if palette is in range + if(RTBL[IndexOfFile] >= RPAL_Length / 16) { + SDL_UnlockSurface(pic); + SDL_FreeSurface(pic); + return NULL; + } + + unsigned char* palettestart = RPAL + (16 * RTBL[IndexOfFile]); + unsigned char * filestart = SSET + (IndexOfFile * ((SIZE_X * SIZE_Y)/2)); + + //Now we can copy to surface + unsigned char *dest = (unsigned char*) (pic->pixels) + i*SIZE_X; + unsigned char pixel; + for(int y = 0; y < SIZE_Y;y++) { + for(int x = 0; x < SIZE_X; x+=2) { + pixel = filestart[ (y*SIZE_X + x) / 2]; + pixel = pixel >> 4; + dest[x] = palettestart[pixel]; + + pixel = filestart[ (y*SIZE_X + x) / 2]; + pixel = pixel & 0x0F; + dest[x+1] = palettestart[pixel]; + } + dest += pic->pitch; + } + } + + SDL_UnlockSurface(pic); + return pic; +} + int Icnfile::getNumFiles() { return NumFiles; Modified: branches/dunks/src/pakfile/Shpfile.cpp =================================================================== --- branches/dunks/src/pakfile/Shpfile.cpp 2007-01-29 12:27:15 UTC (rev 129) +++ branches/dunks/src/pakfile/Shpfile.cpp 2007-08-14 18:21:25 UTC (rev 130) @@ -1,3 +1,4 @@ +#include "Application.h" #include "pakfile/Shpfile.h" #include <SDL_endian.h> @@ -21,8 +22,9 @@ } } -SDL_Surface *Shpfile::getPicture(Uint32 IndexOfFile, SDL_Palette *palette) +SDL_Surface *Shpfile::getPicture(Uint32 IndexOfFile) { + SDL_Palette *palette = Application::Instance()->Screen()->format->palette; SDL_Surface *pic = NULL; unsigned char *DecodeDestination = NULL; unsigned char *ImageOut = NULL; @@ -114,7 +116,6 @@ if((pic = SDL_CreateRGBSurface(SDL_SWSURFACE,sizeX,sizeY,8,0,0,0,0))== NULL) { return NULL; } - SDL_SetColors(pic, palette->colors, 0, palette->ncolors); SDL_LockSurface(pic); @@ -125,15 +126,193 @@ SDL_UnlockSurface(pic); - SDL_SetColorKey(pic, SDL_SRCCOLORKEY, 0); + SDL_SetColorKey(pic, SDL_SRCCOLORKEY, 0); if(ImageOut != NULL) { free(ImageOut); } - return pic; } +SDL_Surface* Shpfile::getPictureArray(unsigned int tilesX, unsigned int tilesY, ...) { + SDL_Palette *palette = Application::Instance()->Screen()->format->palette; + SDL_Surface *pic = NULL; + unsigned char *DecodeDestination = NULL; + unsigned char *ImageOut = NULL; + Uint32 i,j; + + Uint32* tiles; + + if((tilesX == 0) || (tilesY == 0)) { + return NULL; + } + + if((tiles = (Uint32*) malloc(tilesX*tilesY*sizeof(Uint32))) == NULL) { + fprintf(stderr,"Shpfile::getPictureArray(): Cannot allocate memory!\n"); + exit(EXIT_FAILURE); + } + + va_list arg_ptr; + va_start(arg_ptr, tilesY); + + for(i = 0; i < tilesX*tilesY; i++) { + tiles[i] = va_arg( arg_ptr, int ); + if(TILE_GETINDEX(tiles[i]) >= NumFiles) { + free(tiles); + fprintf(stderr,"Shpfile::getPictureArray(): There exist only %d files in this *.shp.\n",NumFiles); + return NULL; + } + } + + va_end(arg_ptr); + + unsigned char sizeY = (Filedata + Index[TILE_GETINDEX(tiles[0])].StartOffset)[2]; + unsigned char sizeX = (Filedata + Index[TILE_GETINDEX(tiles[0])].StartOffset)[3]; + + for(i = 1; i < tilesX*tilesY; i++) { + if(((Filedata + Index[TILE_GETINDEX(tiles[i])].StartOffset)[2] != sizeY) + || ((Filedata + Index[TILE_GETINDEX(tiles[i])].StartOffset)[3] != sizeX)) { + free(tiles); + fprintf(stderr,"Shpfile::getPictureArray(): Not all pictures have the same size!\n"); + exit(EXIT_FAILURE); + } + } + + // create new picture surface + if((pic = SDL_CreateRGBSurface(SDL_HWSURFACE,sizeX*tilesX,sizeY*tilesY,8,0,0,0,0)) == NULL) { + fprintf(stderr,"Shpfile::getPictureArray(): Cannot create Surface.\n"); + exit(EXIT_FAILURE); + } + + SDL_SetColors(pic, palette->colors, 0, palette->ncolors); + SDL_LockSurface(pic); + + for(j = 0; j < tilesY; j++) { + for(i = 0; i < tilesX; i++) { + + unsigned char * Fileheader = Filedata + Index[TILE_GETINDEX(tiles[j*tilesX+i])].StartOffset; + unsigned char type = Fileheader[0]; + + /* size and also checksum */ + Uint16 size = SDL_SwapLE16(*((Uint16*) (Fileheader + 8))); + + if((ImageOut = (unsigned char*) calloc(1,sizeX*sizeY)) == NULL) { + free(tiles); + fprintf(stderr,"Shpfile::getPictureArray(): Cannot allocate memory!\n"); + exit(EXIT_FAILURE); + } + + switch(type) { + + case 0: + { + if( (DecodeDestination = (unsigned char*) calloc(1,size)) == NULL) { + free(ImageOut); + free(tiles); + fprintf(stderr,"Shpfile::getPictureArray(): Cannot allocate memory!\n"); + exit(EXIT_FAILURE); + } + + if(decode80(Fileheader + 10,DecodeDestination,size) == -1) { + fprintf(stderr,"Warning: Checksum-Error in Shp-File\n"); + } + + shp_correct_lf(DecodeDestination,ImageOut, size); + + free(DecodeDestination); + } break; + + case 1: + { + if( (DecodeDestination = (unsigned char*) calloc(1,size)) == NULL) { + free(ImageOut); + free(tiles); + fprintf(stderr,"Shpfile::getPictureArray(): Cannot allocate memory!\n"); + exit(EXIT_FAILURE); + } + + if(decode80(Fileheader + 10 + 16,DecodeDestination,size) == -1) { + fprintf(stderr,"Warning: Checksum-Error in Shp-File\n"); + } + + shp_correct_lf(DecodeDestination, ImageOut, size); + + apply_pal_offsets(Fileheader + 10,ImageOut,sizeX*sizeY); + + free(DecodeDestination); + } break; + + case 2: + { + shp_correct_lf(Fileheader+10, ImageOut,size); + } break; + + case 3: + { + shp_correct_lf(Fileheader + 10 + 16, ImageOut,size); + apply_pal_offsets(Fileheader + 10,ImageOut,sizeX*sizeY); + } break; + + default: + { + fprintf(stderr,"Shpfile: Type %d in SHP-Files not supported!\n",type); + exit(EXIT_FAILURE); + } + } + + //Now we can copy line by line + switch(TILE_GETTYPE(tiles[i])) { + case TILE_NORMAL: + { + for(int y = 0; y < sizeY; y++) { + memcpy( ((char*) (pic->pixels)) + i*sizeX + (y+j*sizeY) * pic->pitch , ImageOut + y * sizeX, sizeX); + } + } break; + + case TILE_FLIPH: + { + for(int y = 0; y < sizeY; y++) { + memcpy( ((char*) (pic->pixels)) + i*sizeX + (y+j*sizeY) * pic->pitch , ImageOut + (sizeY-1-y) * sizeX, sizeX); + } + } break; + + case TILE_FLIPV: + { + for(int y = 0; y < sizeY; y++) { + for(int x = 0; x < sizeX; x++) { + *(((char*) (pic->pixels)) + i*sizeX + (y+j*sizeY) * pic->pitch + x) = *(ImageOut + y * sizeX + (sizeX-1-x)); + } + } + } break; + + case TILE_ROTATE: + { + for(int y = 0; y < sizeY; y++) { + for(int x = 0; x < sizeX; x++) { + *(((char*) (pic->pixels)) + i*sizeX + (y+j*sizeY) * pic->pitch + x) = *(ImageOut + (sizeY-1-y) * sizeX + (sizeX-1-x)); + } + } + } break; + + default: + { + fprintf(stderr,"Shpfile: Invalid type for this parameter. Must be one of TILE_NORMAL, TILE_FLIPH, TILE_FLIPV or TILE_ROTATE!\n"); + exit(EXIT_FAILURE); + } break; + } + + if(ImageOut != NULL) { + free(ImageOut); + } + } + } + + free(tiles); + + SDL_UnlockSurface(pic); + return pic; +} + void Shpfile::readIndex() { // First get number of files in shp-file Modified: branches/dunks/src/pakview.cpp =================================================================== --- branches/dunks/src/pakview.cpp 2007-01-29 12:27:15 UTC (rev 129) +++ branches/dunks/src/pakview.cpp 2007-08-14 18:21:25 UTC (rev 130) @@ -1,11 +1,17 @@ #include "Application.h" +#include "DataCache.h" +#include "Gfx.h" #include "Settings.h" #include "State.h" #include "ResMan.h" +#include "pakview.h" #include "pakfile/Palette.h" #include "gui2/Button.h" +#include "houses.h" +#include "boost/bind.hpp" + namespace boost { void throw_exception(std::exception const & e) @@ -20,20 +26,27 @@ public: PakViewState() { - int len; - unsigned char* data = ResMan::Instance()->readFile("INTRO:INTRO.PAL", &len); + img = 0; + house = HOUSE_ATREIDES; + m_button = new BoringButton("Click me, bitte!"); + m_button->setSize(SPoint(160, 50)); + m_button->setPosition(SPoint(10, 10)); + m_button->setVisible(true); + m_button->onClick.connect( + boost::bind(&PakViewState::NextImg, this) ); - Palettefile pal (data, len); + m_houseBut = new BoringButton("Change house"); + m_houseBut->setSize(SPoint(132, 50)); + m_houseBut->setPosition(SPoint(200, 10)); + m_houseBut->setVisible(true); + m_houseBut->onClick.connect( + boost::bind(&PakViewState::SwitchHouse, this) ); + + m_test = DataCache::Instance()->getObjImg(img, house); - Application::Instance()->SetPalette(); + Application::Instance()->RootWidget()->addChild(m_button); + Application::Instance()->RootWidget()->addChild(m_houseBut); - m_button = new BoringButton("Test"); - m_button->setSize(100, 50); - m_button->setPos(10, 10); - m_button->setVisible(true); - - Application::Instance()->RootWidget()->addChild(m_button); - }; ~PakViewState() @@ -43,13 +56,35 @@ int Execute(float dt) { + m_test->blitToScreenCentered(); return 0; }; + void NextImg() + { + img++; + + if (img == NUM_OBJIMGS) + img = 0; + + m_test = DataCache::Instance()->getObjImg(img, house); + }; + + void SwitchHouse() + { + house++; + fprintf(stderr, "HOUSE CHANGED\n"); + if (house == NUM_HOUSES) + house = 0; + m_test = DataCache::Instance()->getObjImg(img, house); + }; + virtual const char* GetName() { return "PakViewState"; } private: - BoringButton* m_button; + BoringButton* m_button, *m_houseBut; + ImagePtr m_test; + int img, house; }; int main(int argc, char *argv[]) @@ -58,6 +93,9 @@ Settings::Instance()->ParseOptions(argc, argv); Application::Instance()->Init(); + + DataCache::Instance(); + //Application::Instance()->PushState( new MainMenuState() ); //Application::Instance()->PushState( new IntroState() ); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dv...@us...> - 2006-12-14 17:36:29
|
Revision: 128 http://svn.sourceforge.net/dunelegacy/?rev=128&view=rev Author: dvalin Date: 2006-12-14 09:36:15 -0800 (Thu, 14 Dec 2006) Log Message: ----------- Raise matPathSearch to make units actually try find other paths than direct path Modified Paths: -------------- trunk/src/Settings.cpp Modified: trunk/src/Settings.cpp =================================================================== --- trunk/src/Settings.cpp 2006-12-12 05:25:16 UTC (rev 127) +++ trunk/src/Settings.cpp 2006-12-14 17:36:15 UTC (rev 128) @@ -37,7 +37,7 @@ //FIXME:Not sure what it exactly does, but setting //it to 1 lowers cpu usage. - settings.maxPathSearch = 1; + settings.maxPathSearch = 50; srand(seed); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dv...@us...> - 2006-12-12 05:25:25
|
Revision: 127 http://svn.sourceforge.net/dunelegacy/?rev=127&view=rev Author: dvalin Date: 2006-12-11 21:25:16 -0800 (Mon, 11 Dec 2006) Log Message: ----------- switch to 8 bit 11050 khz sampling Modified Paths: -------------- trunk/src/Menu.cpp Modified: trunk/src/Menu.cpp =================================================================== --- trunk/src/Menu.cpp 2006-11-28 20:57:33 UTC (rev 126) +++ trunk/src/Menu.cpp 2006-12-12 05:25:16 UTC (rev 127) @@ -5525,12 +5525,12 @@ SDL_WM_SetCaption("Dune Legacy", "Dune Legacy"); fprintf(stdout, "initialising sound.....\n");fflush(stdout); - if ( Mix_OpenAudio(/*MIX_DEFAULT_FREQUENCY*/11025, MIX_DEFAULT_FORMAT/*AUDIO_U16*/, 2, 512) < 0 ) + if ( Mix_OpenAudio(/*MIX_DEFAULT_FREQUENCY*/11025, AUDIO_U8, 2, 512) < 0 ) { // SDL_Quit(); - fprintf(stderr,"Warning: Couldn't set 11025 Hz 16-bit audio\n- Reason: %s\n",SDL_GetError()); + fprintf(stderr,"Warning: Couldn't set 11025 Hz 8-bit audio\n- Reason: %s\n",SDL_GetError()); // exit(1); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <shu...@us...> - 2006-11-28 20:57:34
|
Revision: 126 http://svn.sourceforge.net/dunelegacy/?rev=126&view=rev Author: shutdownrunner Date: 2006-11-28 12:57:33 -0800 (Tue, 28 Nov 2006) Log Message: ----------- - Fixed doxygen configuration. Now it won't mix gui and gui2 widgets Modified Paths: -------------- branches/dunks/doxygen.conf Modified: branches/dunks/doxygen.conf =================================================================== --- branches/dunks/doxygen.conf 2006-11-28 20:33:50 UTC (rev 125) +++ branches/dunks/doxygen.conf 2006-11-28 20:57:33 UTC (rev 126) @@ -75,7 +75,7 @@ INPUT = include/ FILE_PATTERNS = *.h RECURSIVE = YES -EXCLUDE = include/gui/*.h +EXCLUDE = include/gui/ EXCLUDE_SYMLINKS = NO EXCLUDE_PATTERNS = EXAMPLE_PATH = This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <shu...@us...> - 2006-11-28 20:33:56
|
Revision: 125 http://svn.sourceforge.net/dunelegacy/?rev=125&view=rev Author: shutdownrunner Date: 2006-11-28 12:33:50 -0800 (Tue, 28 Nov 2006) Log Message: ----------- - Added label(somehow didn't do it the previous time) Added Paths: ----------- branches/dunks/include/gui2/Label.h branches/dunks/src/gui2/Label.cpp Added: branches/dunks/include/gui2/Label.h =================================================================== --- branches/dunks/include/gui2/Label.h (rev 0) +++ branches/dunks/include/gui2/Label.h 2006-11-28 20:33:50 UTC (rev 125) @@ -0,0 +1,33 @@ +#ifndef DUNE_GUI2_LABEL_H +#define DUNE_GUI2_LABEL_H + +#include "gui2/Widget.h" +#include <string> + +/* Label widget using dune's fonts +*/ +class Label : public Widget +{ +public: + //! @name Constructors & Destructor + //@{ + + /*! + Caption of label should always be set when constructing label + @param caption std::string a caption of label + @param bgcolour sets background colour of label. 115(dune yellow) by default + */ + Label(std::string caption, int bgcolour = 115); + + ~Label(); + //@} + + virtual void draw(SDL_Surface* dest, SPoint off); + +protected: + + SDL_Surface * m_surface; + std::string m_caption; +}; + +#endif //DUNE_GUI2_LABEL_H Added: branches/dunks/src/gui2/Label.cpp =================================================================== --- branches/dunks/src/gui2/Label.cpp (rev 0) +++ branches/dunks/src/gui2/Label.cpp 2006-11-28 20:33:50 UTC (rev 125) @@ -0,0 +1,54 @@ +#include "gui2/Label.h" +#include <stdio.h> +#include "Colours.h" +#include "Font.h" +#include "Application.h" +#include "Gfx.h" + +Label::Label(std::string caption, int bgcolour) +{ + m_caption = caption; + Font* font = FontManager::Instance()->getFont("INTRO:INTRO.FNT"); + + Uint16 textw, texth; + + font->extents(m_caption.c_str(), textw, texth); + + /*If surface width was not %4 == 0 then you'd get a text in italics */ + m_surface = SDL_CreateRGBSurface(SDL_SWSURFACE, textw + 4-(textw%4) , texth, 8, + 0, 0, 0, 0); + + assert(m_surface != NULL); + + SDL_LockSurface(m_surface); + + SDL_Palette* pal = Application::Instance()->Screen()->format->palette; + + SDL_SetColors(m_surface, pal->colors, 0, pal->ncolors); + + SDL_FillRect(m_surface, NULL, bgcolour); + + font->render(m_caption.c_str(), m_surface, + m_surface->w/2 - textw/2, + m_surface->h/2 - texth/2, 49); + SDL_UnlockSurface(m_surface); + +// Is it needed in case of label. It's not clickable or anything. +// Widget::setSize(SPoint(textw, texth)); +}; + +Label::~Label() +{ + +}; + +void Label::draw(SDL_Surface* dest, SPoint off) +{ + if (!m_visible) return; + + Rect destrect (off.x + x, off.y + y, 0, 0); + + assert(m_surface != NULL); + SDL_BlitSurface(m_surface, NULL, dest, &destrect); + +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <shu...@us...> - 2006-11-23 22:37:28
|
Revision: 124 http://svn.sourceforge.net/dunelegacy/?rev=124&view=rev Author: shutdownrunner Date: 2006-11-23 14:37:25 -0800 (Thu, 23 Nov 2006) Log Message: ----------- - Added label. It will be useful I hope - And a small test of my image cropping skills. Could someone with a bit of free time make a list of how to cut images to make menus, in-game panels, etc. ? Modified Paths: -------------- branches/dunks/include/Gfx.h branches/dunks/include/MainMenu.h branches/dunks/include/OptionsMenu.h branches/dunks/src/Gfx.cpp branches/dunks/src/IntroState.cpp branches/dunks/src/MainMenu.cpp branches/dunks/src/OptionsMenu.cpp branches/dunks/src/SConscript Modified: branches/dunks/include/Gfx.h =================================================================== --- branches/dunks/include/Gfx.h 2006-11-23 18:30:57 UTC (rev 123) +++ branches/dunks/include/Gfx.h 2006-11-23 22:37:25 UTC (rev 124) @@ -113,7 +113,6 @@ */ SDL_Surface* resizeSurface(SDL_Surface *surface, double ratio); -void scale2x(SDL_Surface *src, SDL_Surface *dst); //@} //------------------------------------------------------------------------------ Modified: branches/dunks/include/MainMenu.h =================================================================== --- branches/dunks/include/MainMenu.h 2006-11-23 18:30:57 UTC (rev 123) +++ branches/dunks/include/MainMenu.h 2006-11-23 22:37:25 UTC (rev 124) @@ -4,6 +4,8 @@ #include "MenuBase.h" #include "gui2/Button.h" #include "gui2/VBox.h" +#include "Gfx.h" +#include "SDL.h" class MainMenuState : public MenuBaseState { @@ -15,11 +17,13 @@ void doSkirmish(); void doSingle(); void doQuit(); + int Execute(float dt); virtual const char* GetName() { return "MainMenuState"; } private: VBox* m_vbox; - + Rect m_rect; + SDL_Surface * m_surf; BoringButton* m_butSingle; BoringButton* m_butMulti; BoringButton* m_butMapEd; Modified: branches/dunks/include/OptionsMenu.h =================================================================== --- branches/dunks/include/OptionsMenu.h 2006-11-23 18:30:57 UTC (rev 123) +++ branches/dunks/include/OptionsMenu.h 2006-11-23 22:37:25 UTC (rev 124) @@ -4,7 +4,6 @@ #include "MenuBase.h" #include "gui2/Button.h" #include "gui2/VBox.h" - #include "SDL.h" @@ -23,7 +22,6 @@ private: VBox* m_vbox; - BoringButton* m_butResolution; BoringButton* m_butWindowMode; BoringButton* m_butOk; Modified: branches/dunks/src/Gfx.cpp =================================================================== --- branches/dunks/src/Gfx.cpp 2006-11-23 18:30:57 UTC (rev 123) +++ branches/dunks/src/Gfx.cpp 2006-11-23 22:37:25 UTC (rev 124) @@ -316,54 +316,6 @@ return resizeSurface(surface, (Uint16)(surface->w*ratio), (Uint16)(surface->h*ratio)); } -// Defines used by scale2x - -#ifndef MAX -#define MAX(a,b) (((a) > (b)) ? (a) : (b)) -#define MIN(a,b) (((a) < (b)) ? (a) : (b)) -#endif - - -#define READINT24(x) ((x)[0]<<16 | (x)[1]<<8 | (x)[2]) -#define WRITEINT24(x, i) {(x)[0]=i>>16; (x)[1]=(i>>8)&0xff; x[2]=i&0xff; } - - -void scale2x(SDL_Surface *src, SDL_Surface *dst) -{ - int looph, loopw; - - Uint8* srcpix = (Uint8*)src->pixels; - Uint8* dstpix = (Uint8*)dst->pixels; - - const int srcpitch = src->pitch; - const int dstpitch = dst->pitch; - const int width = src->w; - const int height = src->h; - - - Uint8 E0, E1, E2, E3, B, D, E, F, H; - for(looph = 0; looph < height; ++looph) - { - for(loopw = 0; loopw < width; ++ loopw) - { - B = *(Uint8*)(srcpix + (MAX(0,looph-1)*srcpitch) + (1*loopw)); - D = *(Uint8*)(srcpix + (looph*srcpitch) + (1*MAX(0,loopw-1))); - E = *(Uint8*)(srcpix + (looph*srcpitch) + (1*loopw)); - F = *(Uint8*)(srcpix + (looph*srcpitch) + (1*MIN(width-1,loopw+1))); - H = *(Uint8*)(srcpix + (MIN(height-1,looph+1)*srcpitch) + (1*loopw)); - - E0 = D == B && B != F && D != H ? D : E; - E1 = B == F && B != D && F != H ? F : E; - E2 = D == H && D != B && H != F ? D : E; - E3 = H == F && D != H && B != F ? F : E; - - *(Uint8*)(dstpix + looph*2*dstpitch + loopw*2*1) = E0; - *(Uint8*)(dstpix + looph*2*dstpitch + (loopw*2+1)*1) = E1; - *(Uint8*)(dstpix + (looph*2+1)*dstpitch + loopw*2*1) = E2; - *(Uint8*)(dstpix + (looph*2+1)*dstpitch + (loopw*2+1)*1) = E3; - } - } -} //------------------------------------------------------------------------------ // Color mapping //------------------------------------------------------------------------------ Modified: branches/dunks/src/IntroState.cpp =================================================================== --- branches/dunks/src/IntroState.cpp 2006-11-23 18:30:57 UTC (rev 123) +++ branches/dunks/src/IntroState.cpp 2006-11-23 22:37:25 UTC (rev 124) @@ -1,6 +1,7 @@ #include "IntroState.h" #include "ResMan.h" #include "Application.h" +#include "Gfx.h" #include "Settings.h" #include "pakfile/Palette.h" #include "boost/bind.hpp" @@ -58,7 +59,7 @@ SDL_SetColors(m_scaledSurface, palette->colors, 0, palette->ncolors); - scale2x(m_animSurface, m_scaledSurface); + m_scaledSurface = resizeSurface(m_animSurface, 2); } bool IntroState::Frame::Execute(float dt) @@ -119,7 +120,7 @@ SDL_SetColors(m_scaledSurface, palette->colors, 0, palette->ncolors); - scale2x(m_animSurface, m_scaledSurface); + m_scaledSurface = resizeSurface(m_animSurface, 2); }; }; } Modified: branches/dunks/src/MainMenu.cpp =================================================================== --- branches/dunks/src/MainMenu.cpp 2006-11-23 18:30:57 UTC (rev 123) +++ branches/dunks/src/MainMenu.cpp 2006-11-23 22:37:25 UTC (rev 124) @@ -3,13 +3,13 @@ #include "Application.h" //#include "DataFile.h" #include "Settings.h" - +#include "ResMan.h" #include "SingleMenu.h" #include "OptionsMenu.h" #include "boost/bind.hpp" +#include "pakfile/Wsafile.h" - MainMenuState::MainMenuState() { //m_menuBackground = (SDL_Surface*)(dataFile[UI_Menu].dat); @@ -83,6 +83,53 @@ m_vbox->reshape(); m_container->addChild(m_vbox); + +//TODO:I guess that most of this should be wrapped into some function as +//we'll be doing a lot of image cropping like this + + int len; + unsigned char * data = ResMan::Instance()->readFile("MENTAT:FARTR.WSA", &len); + + SDL_Palette* palette = Application::Instance()->Screen()->format->palette; + + Wsafile * m_wsa = new Wsafile(data, len); + + SDL_Surface * tmp = copySurface(m_wsa->getPicture(1, palette)); + + m_surf = SDL_CreateRGBSurface(SDL_SWSURFACE, 258, 65, 8,0,0,0,0); + + SDL_SetColors(m_surf, palette->colors, 0, palette->ncolors); + + Rect src (6,31, 82, 65); + + Rect cp(0, 0, 82, 65); + + SDL_BlitSurface(tmp, &src, m_surf, &cp); + + + data = ResMan::Instance()->readFile("MENTAT:FHARK.WSA", &len); + + m_wsa = new Wsafile(data, len); + tmp = copySurface(m_wsa->getPicture(1, palette)); + + cp.setPosition(SPoint(88, 0)); + + SDL_BlitSurface(tmp, &src, m_surf, &cp); + + data = ResMan::Instance()->readFile("MENTAT:FORDOS.WSA", &len); + + m_wsa = new Wsafile(data, len); + tmp = copySurface(m_wsa->getPicture(1, palette)); + + cp.setPosition(SPoint(176, 0)); + SDL_BlitSurface(tmp, &src, m_surf, &cp); + + m_surf = resizeSurface(m_surf, 2); + + m_rect.setPosition(SPoint(Settings::Instance()->GetWidth() / 2 - m_surf->w/2, + Settings::Instance()->GetHeight() / 4)); + + m_rect.setSize(UPoint(m_surf->w, m_surf->h)); } MainMenuState::~MainMenuState() @@ -128,13 +175,12 @@ { Application::Instance()->RootWidget()->deleteChild(m_vbox); State::JustMadeInactive(); -} +}*/ int MainMenuState::Execute(float dt) { - Application::Instance()->BlitCentered(m_menuBackground); + Application::Instance()->Blit(m_surf, NULL, &m_rect); return 0; } -*/ Modified: branches/dunks/src/OptionsMenu.cpp =================================================================== --- branches/dunks/src/OptionsMenu.cpp 2006-11-23 18:30:57 UTC (rev 123) +++ branches/dunks/src/OptionsMenu.cpp 2006-11-23 22:37:25 UTC (rev 124) @@ -2,6 +2,9 @@ #include "Application.h" //#include "DataFile.h" +#include "ResMan.h" +#include "Gfx.h" +#include "pakfile/Wsafile.h" #include "Settings.h" #include "boost/bind.hpp" @@ -65,8 +68,8 @@ (m_vbox->w / 2); m_vbox->setPosition(UPoint(x - 5, 312)); m_vbox->reshape(); - m_container->addChild(m_vbox); + } OptionsMenuState::~OptionsMenuState() @@ -125,4 +128,3 @@ else m_butWindowMode->setCaption("Window mode"); } - Modified: branches/dunks/src/SConscript =================================================================== --- branches/dunks/src/SConscript 2006-11-23 18:30:57 UTC (rev 123) +++ branches/dunks/src/SConscript 2006-11-23 22:37:25 UTC (rev 124) @@ -39,6 +39,7 @@ "gui2/Container.cpp", "gui2/Button.cpp", "gui2/VBox.cpp", + "gui2/Label.cpp", ] This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dv...@us...> - 2006-11-23 18:31:09
|
Revision: 123 http://svn.sourceforge.net/dunelegacy/?rev=123&view=rev Author: dvalin Date: 2006-11-23 10:30:57 -0800 (Thu, 23 Nov 2006) Log Message: ----------- x86_64 build fix from JttL Modified Paths: -------------- branches/dunks/include/Log.h branches/dunks/src/Log.cpp Modified: branches/dunks/include/Log.h =================================================================== --- branches/dunks/include/Log.h 2006-11-21 17:21:06 UTC (rev 122) +++ branches/dunks/include/Log.h 2006-11-23 18:30:57 UTC (rev 123) @@ -198,7 +198,7 @@ int indentLevel; bool checkMessageVerbosity(ConstString logSystem, LogVerbosity verbosity); - void doLog(ConstString logSystem, LogVerbosity verbosity, const char *format, va_list args); + void doLog(ConstString logSystem, LogVerbosity verbosity, const char *format, ...); }; Modified: branches/dunks/src/Log.cpp =================================================================== --- branches/dunks/src/Log.cpp 2006-11-21 17:21:06 UTC (rev 122) +++ branches/dunks/src/Log.cpp 2006-11-23 18:30:57 UTC (rev 123) @@ -138,8 +138,9 @@ return true; } -void Log::doLog(ConstString logSystem, LogVerbosity verbosity, const char *format, va_list args) +void Log::doLog(ConstString logSystem, LogVerbosity verbosity, const char *format, ...) { + va_list args ; static char message[LOG_MAX_STRING_LENGTH]; static char formated[LOG_MAX_STRING_LENGTH]; const char *verb; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |