Switched to Renderer::instance()->apply_config() to switch video mode (which doesn't yet work as apply_config() is incomplete)
SVN-Revision: 6043
-* make a proper class out of supertux/resources.hpp
+* Renderer::apply_config() needs to handle fullscreen switching
int main(int argc, char** argv)
{
int main(int argc, char** argv)
{
- return supertux_main(argc, argv);
+ return Main().main(argc, argv);
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
+#include "supertux/main.hpp"
+
#include <config.h>
#include <version.h>
#include <config.h>
#include <version.h>
namespace { DrawingContext *context_pointer; }
namespace { DrawingContext *context_pointer; }
-static void init_config()
+void
+Main::init_config()
{
g_config = new Config();
try {
{
g_config = new Config();
try {
-static void init_tinygettext()
+void
+Main::init_tinygettext()
{
tinygettext::Log::set_log_info_callback(0);
dictionary_manager.set_filesystem(std::auto_ptr<tinygettext::FileSystem>(new PhysFSFileSystem));
{
tinygettext::Log::set_log_info_callback(0);
dictionary_manager.set_filesystem(std::auto_ptr<tinygettext::FileSystem>(new PhysFSFileSystem));
-static void init_physfs(const char* argv0)
+ void
+Main::init_physfs(const char* argv0)
{
if(!PHYSFS_init(argv0)) {
std::stringstream msg;
{
if(!PHYSFS_init(argv0)) {
std::stringstream msg;
PHYSFS_freeList(searchpath);
}
PHYSFS_freeList(searchpath);
}
-static void print_usage(const char* argv0)
+void
+Main::print_usage(const char* argv0)
{
fprintf(stderr, _("Usage: %s [OPTIONS] [LEVELFILE]\n\n"), argv0);
fprintf(stderr,
{
fprintf(stderr, _("Usage: %s [OPTIONS] [LEVELFILE]\n\n"), argv0);
fprintf(stderr,
/**
* Options that should be evaluated prior to any initializations at all go here
*/
/**
* Options that should be evaluated prior to any initializations at all go here
*/
-static bool pre_parse_commandline(int argc, char** argv)
+bool
+Main::pre_parse_commandline(int argc, char** argv)
{
for(int i = 1; i < argc; ++i) {
std::string arg = argv[i];
{
for(int i = 1; i < argc; ++i) {
std::string arg = argv[i];
/**
* Options that should be evaluated after config is read go here
*/
/**
* Options that should be evaluated after config is read go here
*/
-static bool parse_commandline(int argc, char** argv)
+bool
+Main::parse_commandline(int argc, char** argv)
{
for(int i = 1; i < argc; ++i) {
std::string arg = argv[i];
{
for(int i = 1; i < argc; ++i) {
std::string arg = argv[i];
{
if(SDL_Init(SDL_INIT_TIMER | SDL_INIT_VIDEO | SDL_INIT_JOYSTICK) < 0) {
std::stringstream msg;
{
if(SDL_Init(SDL_INIT_TIMER | SDL_INIT_VIDEO | SDL_INIT_JOYSTICK) < 0) {
std::stringstream msg;
{
g_config->random_seed = systemRandom.srand(g_config->random_seed);
{
g_config->random_seed = systemRandom.srand(g_config->random_seed);
//log_info << "Using random seed " << config->random_seed << how << std::endl;
}
//log_info << "Using random seed " << config->random_seed << how << std::endl;
}
+void
+Main::init_video()
{
// FIXME: Add something here
SCREEN_WIDTH = 800;
{
// FIXME: Add something here
SCREEN_WIDTH = 800;
<< " Area: " << g_config->aspect_width << "x" << g_config->aspect_height << std::endl;
}
<< " Area: " << g_config->aspect_width << "x" << g_config->aspect_height << std::endl;
}
-static void init_audio()
+void
+Main::init_audio()
{
sound_manager = new SoundManager();
{
sound_manager = new SoundManager();
sound_manager->enable_music(g_config->music_enabled);
}
sound_manager->enable_music(g_config->music_enabled);
}
-static void quit_audio()
+void
+Main::quit_audio()
{
if(sound_manager != NULL) {
delete sound_manager;
{
if(sound_manager != NULL) {
delete sound_manager;
-void wait_for_event(float min_delay, float max_delay)
+void
+Main::wait_for_event(float min_delay, float max_delay)
{
assert(min_delay <= max_delay);
{
assert(min_delay <= max_delay);
-std::istream* physfs_open_file(const char* name)
-{
- return new IFileStream(name);
-}
-
-void physfs_free_list(char** name)
-{
- PHYSFS_freeList(name);
-}
-
-int supertux_main(int argc, char** argv)
+int
+Main::main(int argc, char** argv)
#ifndef HEADER_SUPERTUX_SUPERTUX_MAIN_HPP
#define HEADER_SUPERTUX_SUPERTUX_MAIN_HPP
#ifndef HEADER_SUPERTUX_SUPERTUX_MAIN_HPP
#define HEADER_SUPERTUX_SUPERTUX_MAIN_HPP
-void init_video();
-void wait_for_event(float min_delay, float max_delay);
+class Main
+{
+private:
+ void init_config();
+ void init_tinygettext();
+ void init_physfs(const char* argv0);
+ void print_usage(const char* argv0);
+ bool parse_commandline(int argc, char** argv);
+ void init_sdl();
+ void init_rand();
+ void init_audio();
+ void quit_audio();
+ bool pre_parse_commandline(int argc, char** argv);
-int supertux_main(int argc, char** argv);
+public:
+ int main(int argc, char** argv);
+ void init_video();
+ void wait_for_event(float min_delay, float max_delay);
+};
if (event.key.keysym.sym == SDLK_F11)
{
g_config->use_fullscreen = !g_config->use_fullscreen;
if (event.key.keysym.sym == SDLK_F11)
{
g_config->use_fullscreen = !g_config->use_fullscreen;
+ Renderer::instance()->apply_config();
MenuManager::recalc_pos();
}
else if (event.key.keysym.sym == SDLK_PRINT ||
MenuManager::recalc_pos();
}
else if (event.key.keysym.sym == SDLK_PRINT ||
case MNID_FULLSCREEN:
if(g_config->use_fullscreen != is_toggled(MNID_FULLSCREEN)) {
g_config->use_fullscreen = !g_config->use_fullscreen;
case MNID_FULLSCREEN:
if(g_config->use_fullscreen != is_toggled(MNID_FULLSCREEN)) {
g_config->use_fullscreen = !g_config->use_fullscreen;
- init_video(); // FIXME: Should call apply_config instead
+ Renderer::instance()->apply_config();
MenuManager::recalc_pos();
g_config->save();
}
MenuManager::recalc_pos();
g_config->save();
}