[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Pingus-CVS] r2704 - in branches/pingus_sdl/src: . editor sound
From: |
jsalmon3 |
Subject: |
[Pingus-CVS] r2704 - in branches/pingus_sdl/src: . editor sound |
Date: |
Tue, 10 Jul 2007 06:12:29 +0200 |
Author: jsalmon3
Date: 2007-07-10 06:12:18 +0200 (Tue, 10 Jul 2007)
New Revision: 2704
Modified:
branches/pingus_sdl/src/editor/editor_screen.cpp
branches/pingus_sdl/src/file_dialog.cpp
branches/pingus_sdl/src/file_dialog_item.cpp
branches/pingus_sdl/src/path_manager.cpp
branches/pingus_sdl/src/pingus_main.cpp
branches/pingus_sdl/src/pingus_menu.cpp
branches/pingus_sdl/src/plf_res_mgr.cpp
branches/pingus_sdl/src/sound/sound.cpp
branches/pingus_sdl/src/sound/sound_res_mgr.cpp
branches/pingus_sdl/src/system.cpp
Log:
Fixed PathManager to look in the data dir, fixed file dialog so you can start a
level now
Modified: branches/pingus_sdl/src/editor/editor_screen.cpp
===================================================================
--- branches/pingus_sdl/src/editor/editor_screen.cpp 2007-07-09 06:51:20 UTC
(rev 2703)
+++ branches/pingus_sdl/src/editor/editor_screen.cpp 2007-07-10 04:12:18 UTC
(rev 2704)
@@ -93,7 +93,7 @@
if (filedialog)
delete filedialog;
close_dialog = false;
- filedialog = new FileDialog(this, ".pingus",
+ filedialog = new FileDialog(this, ".scm",
path_manager.complete("levels/"), for_loading);
filedialog->preload();
}
Modified: branches/pingus_sdl/src/file_dialog.cpp
===================================================================
--- branches/pingus_sdl/src/file_dialog.cpp 2007-07-09 06:51:20 UTC (rev
2703)
+++ branches/pingus_sdl/src/file_dialog.cpp 2007-07-10 04:12:18 UTC (rev
2704)
@@ -17,6 +17,8 @@
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+#include <algorithm>
+
#include "gettext.h"
#include "system.hpp"
#include "pingus_menu_manager.hpp"
@@ -298,7 +300,7 @@
gc.draw(sprite, Vector3f(gc.get_width ()/2 - sprite.get_width
()/2,
gc.get_height ()/2 - sprite.get_height ()/2));
gc.draw_rect(gc.get_width() / 2 - 285, gc.get_height() / 2 -
160,
- gc.get_width() / 2 + 285, gc.get_height() / 2 +
160, Color(0,0,0));
+ gc.get_width() / 2 + 285, gc.get_height() / 2 + 160,
Color(0,0,0));
gc.print_center(Fonts::chalk_large, gc.get_width()/2,
gc.get_height()/2 - 220,
current_file.friendly_name == "" ? current_file.name :
current_file.friendly_name);
@@ -319,33 +321,33 @@
file_list.clear();
current_offset=0;
+ System::Directory d;
+ System::DirectoryIter diter;
FileItem f;
// Get the list of files and folders in the current folder
-#if 0
- CL_DirectoryScanner scanner;
- scanner.scan(current_path, "*");
- while (scanner.next())
+ d = System::opendir(current_path, "*");
+ for (diter = d.begin(); diter != d.end(); ++diter)
{
- if (scanner.get_name() != "." && scanner.get_name() !=
".."
- && scanner.get_name() != ".svn" &&
scanner.is_directory())
+ if ((*diter).name != "." && (*diter).name != ".."
+ && (*diter).name != ".svn" && (*diter).type ==
System::DirectoryEntry::DE_DIRECTORY)
{
- f.name = scanner.get_name();
+ f.name = (*diter).name;
f.is_directory = true;
file_list.push_back(f);
}
}
- scanner.scan(current_path, "*" + file_mask);
- while (scanner.next())
+ d = System::opendir(current_path, "*" + file_mask);
+ for (diter = d.begin(); diter != d.end(); ++diter)
{
- f.name = scanner.get_name();
+ f.name = (*diter).name;
f.is_directory = false;
file_list.push_back(f);
}
std::sort(file_list.begin(), file_list.end(), &FileItemCompare);
-#endif
+
current_offset = 0;
offset_changed();
}
Modified: branches/pingus_sdl/src/file_dialog_item.cpp
===================================================================
--- branches/pingus_sdl/src/file_dialog_item.cpp 2007-07-09 06:51:20 UTC
(rev 2703)
+++ branches/pingus_sdl/src/file_dialog_item.cpp 2007-07-10 04:12:18 UTC
(rev 2704)
@@ -54,9 +54,9 @@
}
else
{
-#if 0
// FIXME: Load thumbnail specific to this level
sprite =
Resource::load_sprite("core/menu/default_level");
+#if 0
// Load information about this file if possible.
CL_InputSourceProvider_File provider(".");
Modified: branches/pingus_sdl/src/path_manager.cpp
===================================================================
--- branches/pingus_sdl/src/path_manager.cpp 2007-07-09 06:51:20 UTC (rev
2703)
+++ branches/pingus_sdl/src/path_manager.cpp 2007-07-10 04:12:18 UTC (rev
2704)
@@ -44,13 +44,10 @@
std::string
PathManager::complete (const std::string& relative_path)
{
- return relative_path;
-#if 0
std::string comp_path = base_path + "/" + relative_path;
pout(PINGUS_DEBUG_PATHMGR) << "PathManager: " << relative_path << " -> " <<
comp_path << std::endl;
return comp_path;
-#endif
}
bool
Modified: branches/pingus_sdl/src/pingus_main.cpp
===================================================================
--- branches/pingus_sdl/src/pingus_main.cpp 2007-07-09 06:51:20 UTC (rev
2703)
+++ branches/pingus_sdl/src/pingus_main.cpp 2007-07-10 04:12:18 UTC (rev
2704)
@@ -578,8 +578,10 @@
exit(EXIT_FAILURE);
}
CFRelease(ref);
+ path_manager.add_path("data");
//path_manager.add_path(CL_String::get_path(std::string(resource_path) +
"/data/"));
#else
+ path_manager.add_path("data");
//path_manager.add_path(CL_String::get_path(CL_System::get_exe_path() +
"/data/"));
//path_manager.add_path(CL_String::get_path(CL_System::get_exe_path() +
"/../data/"));
//path_manager.add_path(CL_String::get_path(CL_System::get_exe_path() +
"/../share/games/pingus/"));
@@ -588,13 +590,13 @@
std::list<std::string> file_list;
file_list.push_back ("data/core.xml");
- // if (!path_manager.find_path (file_list))
- // {
- // std::cout << "Error: Couldn't find 'data/core.xml', please set the
enviroment variable\n"
- // << "PINGUS_DATADIR to the path of the file
`data/core.scr' or use the\n"
- // << "-d option." << std::endl;
- // exit(EXIT_FAILURE);
- // }
+ if (!path_manager.find_path (file_list))
+ {
+ std::cout << "Error: Couldn't find 'data/core.xml', please set the
enviroment variable\n"
+ << "PINGUS_DATADIR to the path of the file `data/core.scr' or
use the\n"
+ << "-d option." << std::endl;
+ exit(EXIT_FAILURE);
+ }
dictionary_manager.add_directory(path_manager.complete("po/"));
// Language is automatically picked from env variable
@@ -641,18 +643,6 @@
std::cout.put('=');
std::cout << std::endl;
-#ifdef HAVE_LIBCLANVORBIS
- std::cout << _("clanVorbis support: ok") << std::endl;
-#else
- std::cout << _("clanVoribs support: missing (.ogg music files will not be
playable)") << std::endl;
-#endif
-
-#ifdef HAVE_LIBCLANMIKMOD
- std::cout << _("clanMikMod support: ok") << std::endl;
-#else
- std::cout << _("clanMikMod support: missing (music files will not be
playable)") << std::endl;
-#endif
-
#ifdef HAVE_GETTEXT
std::cout << _("getext support: ok") << std::endl;
std::cout << _("gettext language: english") << std::endl;
@@ -723,10 +713,10 @@
bool successfull = true;
if (!System::exist(levelfile))
{
- if (System::exist(levelfile + ".xml"))
- levelfile += ".pingus";
- else if (System::exist("levels/" + levelfile + ".pingus"))
- levelfile = "levels/" + levelfile + ".pingus";
+ if (System::exist(levelfile + ".scm"))
+ levelfile += ".scm";
+ else if (System::exist("levels/" + levelfile + ".scm"))
+ levelfile = "levels/" + levelfile + ".scm";
else
{
pout << _("PingusMain: Levelfile not found, ignoring: ") <<
levelfile << std::endl;
Modified: branches/pingus_sdl/src/pingus_menu.cpp
===================================================================
--- branches/pingus_sdl/src/pingus_menu.cpp 2007-07-09 06:51:20 UTC (rev
2703)
+++ branches/pingus_sdl/src/pingus_menu.cpp 2007-07-10 04:12:18 UTC (rev
2704)
@@ -112,7 +112,7 @@
{
if (filedialog)
delete filedialog;
- filedialog = new FileDialog(this, ".pingus",
+ filedialog = new FileDialog(this, ".scm",
path_manager.complete("levels/"), true);
manager->push_menu (filedialog);
}
@@ -234,7 +234,7 @@
PingusMenu::load(const std::string &file, const std::string &filemask)
{
// Level
- if (filemask == ".pingus")
+ if (filemask == ".scm")
do_contrib(file);
// Worldmap
else if (filemask == ".xml")
Modified: branches/pingus_sdl/src/plf_res_mgr.cpp
===================================================================
--- branches/pingus_sdl/src/plf_res_mgr.cpp 2007-07-09 06:51:20 UTC (rev
2703)
+++ branches/pingus_sdl/src/plf_res_mgr.cpp 2007-07-10 04:12:18 UTC (rev
2704)
@@ -96,7 +96,7 @@
PingusLevel
PLFResMgr::load_plf(const std::string& res_name)
{
- return load_plf_raw(res_name, path_manager.complete("levels/" + res_name +
".pingus"));
+ return load_plf_raw(res_name, path_manager.complete("levels/" + res_name +
".scm"));
}
Modified: branches/pingus_sdl/src/sound/sound.cpp
===================================================================
--- branches/pingus_sdl/src/sound/sound.cpp 2007-07-09 06:51:20 UTC (rev
2703)
+++ branches/pingus_sdl/src/sound/sound.cpp 2007-07-10 04:12:18 UTC (rev
2704)
@@ -112,7 +112,7 @@
PingusSound::play_music(const std::string & name, float volume)
{
assert (sound);
- sound->real_play_music(path_manager.complete ("data/music/" + name), volume);
+ sound->real_play_music(path_manager.complete ("music/" + name), volume);
}
void
Modified: branches/pingus_sdl/src/sound/sound_res_mgr.cpp
===================================================================
--- branches/pingus_sdl/src/sound/sound_res_mgr.cpp 2007-07-09 06:51:20 UTC
(rev 2703)
+++ branches/pingus_sdl/src/sound/sound_res_mgr.cpp 2007-07-10 04:12:18 UTC
(rev 2704)
@@ -32,7 +32,7 @@
if (i == sound_map.end())
{
- std::string filename = path_manager.complete("data/sounds/" + name +
".wav");
+ std::string filename = path_manager.complete("sounds/" + name + ".wav");
Mix_Chunk* chunk = Mix_LoadWAV(filename.c_str());
pout(PINGUS_DEBUG_LOADING) << "SoundResMgr: Loading sound from disk: "
<< name << " -> " << filename << std::endl;
Modified: branches/pingus_sdl/src/system.cpp
===================================================================
--- branches/pingus_sdl/src/system.cpp 2007-07-09 06:51:20 UTC (rev 2703)
+++ branches/pingus_sdl/src/system.cpp 2007-07-10 04:12:18 UTC (rev 2704)
@@ -91,22 +91,31 @@
}
#else /* WIN32 */
WIN32_FIND_DATA coFindData;
- std::string FindFileDir = pathname + "\\" + pattern;
- std::string FileLocation;
+ std::string FindFileDir = pathname + "/" + pattern;
HANDLE hFind = FindFirstFile(TEXT(FindFileDir.c_str()),&coFindData);
if (hFind == INVALID_HANDLE_VALUE)
{
- std::cout << "System: Couldn't open: " << pathname << std::endl;
+ if (GetLastError() != ERROR_FILE_NOT_FOUND)
+ std::cout << "System: Couldn't open: " << pathname << std::endl;
}
+ else
+ {
+ do
+ {
+ if (coFindData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
+ {
+ dir_list.push_back(DirectoryEntry(coFindData.cFileName,
DirectoryEntry::DE_DIRECTORY));
+ }
+ else
+ {
+ dir_list.push_back(DirectoryEntry(coFindData.cFileName,
DirectoryEntry::DE_FILE));
+ }
+ }
+ while (FindNextFile(hFind,&coFindData));
- do
- {
- dir_list.push_back(DirectoryEntry(coFindData.cFileName));
+ FindClose(hFind);
}
- while (FindNextFile(hFind,&coFindData));
-
- FindClose(hFind);
#endif
return dir_list;
@@ -438,10 +447,10 @@
/** Read file and create a checksum and return it */
std::string
-System::checksum (std::string filename)
+System::checksum(std::string filename)
{
FILE* in;
- int bytes_read;
+ size_t bytes_read;
char buffer[4096];
long int checksum = 0;
@@ -455,14 +464,14 @@
do
{
- bytes_read = fread (buffer, sizeof (char), 4096, in);
+ bytes_read = fread(buffer, sizeof (char), 4096, in);
if (bytes_read == -1)
{
throw PingusError("System:checksum: file read error");
}
- for (int i=0; i < bytes_read; ++i)
+ for (size_t i=0; i < bytes_read; ++i)
checksum = checksum * 17 + buffer[i];
}
while (bytes_read != 0);
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Pingus-CVS] r2704 - in branches/pingus_sdl/src: . editor sound,
jsalmon3 <=