[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Pingus-CVS] r3740 - in trunk/pingus: . src src/components
From: |
grumbel at BerliOS |
Subject: |
[Pingus-CVS] r3740 - in trunk/pingus: . src src/components |
Date: |
Tue, 8 Jul 2008 11:48:02 +0200 |
Author: grumbel
Date: 2008-07-08 11:48:01 +0200 (Tue, 08 Jul 2008)
New Revision: 3740
Removed:
trunk/pingus/src/exit_menu.cpp
trunk/pingus/src/exit_menu.hpp
trunk/pingus/src/pingus_menu_manager.cpp
trunk/pingus/src/pingus_menu_manager.hpp
Modified:
trunk/pingus/SConstruct
trunk/pingus/src/components/menu_button.cpp
trunk/pingus/src/components/menu_button.hpp
trunk/pingus/src/pingus_main.cpp
trunk/pingus/src/pingus_menu.cpp
trunk/pingus/src/pingus_menu.hpp
Log:
Simplified PingusMenu again, ExitMenu and PingusMenuManager got removed in the
process
Modified: trunk/pingus/SConstruct
===================================================================
--- trunk/pingus/SConstruct 2008-07-08 09:41:52 UTC (rev 3739)
+++ trunk/pingus/SConstruct 2008-07-08 09:48:01 UTC (rev 3740)
@@ -99,7 +99,6 @@
'src/surface.cpp',
'src/collision_mask.cpp',
-'src/exit_menu.cpp',
'src/file_reader.cpp',
'src/sexpr_file_reader.cpp',
'src/sexpr_file_writer.cpp',
@@ -166,8 +165,6 @@
'src/pingus_demo.cpp',
'src/pingus_main.cpp',
'src/pingus_menu.cpp',
-'src/pingus_menu_manager.cpp',
-'src/pingus_sub_menu.cpp',
'src/plf_res_mgr.cpp',
'src/option_menu.cpp',
'src/res_descriptor.cpp',
Modified: trunk/pingus/src/components/menu_button.cpp
===================================================================
--- trunk/pingus/src/components/menu_button.cpp 2008-07-08 09:41:52 UTC (rev
3739)
+++ trunk/pingus/src/components/menu_button.cpp 2008-07-08 09:48:01 UTC (rev
3740)
@@ -22,8 +22,7 @@
#include "../gettext.h"
#include "menu_button.hpp"
-
-
+
MenuButton::MenuButton(PingusMenu* menu_,
const Vector2i& pos_,
const std::string& text_, const std::string& desc_)
@@ -132,5 +131,11 @@
&& y < y_pos + int(surface_p.get_height()) / 2);
}
-
+void
+MenuButton::set_pos(int x, int y)
+{
+ x_pos = x;
+ y_pos = y;
+}
+
/* EOF */
Modified: trunk/pingus/src/components/menu_button.hpp
===================================================================
--- trunk/pingus/src/components/menu_button.hpp 2008-07-08 09:41:52 UTC (rev
3739)
+++ trunk/pingus/src/components/menu_button.hpp 2008-07-08 09:48:01 UTC (rev
3740)
@@ -23,9 +23,8 @@
#include "math/vector2i.hpp"
#include "../gui/component.hpp"
-
class PingusMenu;
-
+
/** Framework for menu buttons */
class MenuButton : public GUI::Component
{
@@ -65,12 +64,13 @@
virtual void on_click ();
+ void set_pos(int x, int y);
+
private:
MenuButton (const MenuButton&);
MenuButton& operator= (const MenuButton&);
};
-
-
+
#endif
/* EOF */
Deleted: trunk/pingus/src/exit_menu.cpp
===================================================================
--- trunk/pingus/src/exit_menu.cpp 2008-07-08 09:41:52 UTC (rev 3739)
+++ trunk/pingus/src/exit_menu.cpp 2008-07-08 09:48:01 UTC (rev 3740)
@@ -1,128 +0,0 @@
-// Pingus - A free Lemmings clone
-// Copyright (C) 2000 Ingo Ruhnke <address@hidden>
-//
-// This program is free software: you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation, either version 3 of the License, or
-// (at your option) any later version.
-//
-// This program is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-//
-// 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 "gettext.h"
-#include "pingus_menu_manager.hpp"
-#include "resource.hpp"
-#include "gui/surface_button.hpp"
-#include "gui/gui_manager.hpp"
-#include "sound/sound.hpp"
-
-
-class ExitMenuYesButton : public GUI::SurfaceButton
-{
-private:
- PingusMenuManager* manager;
-public:
- ExitMenuYesButton (PingusMenuManager* m)
- : GUI::SurfaceButton(Display::get_width()/2 - 80,
- Display::get_height()/2 + 15,
- ResDescriptor("core/menu/exit_button_normal"),
- ResDescriptor("core/menu/exit_button_pressed"),
- ResDescriptor("core/menu/exit_button_hover")),
- manager (m)
- {
- }
-
- void draw (DrawingContext& gc) {
- SurfaceButton::draw(gc);
- gc.print_right(Fonts::chalk_large, Display::get_width()/2 - 80,
- Display::get_height()/2 + 15, _("Yes"));
- }
-
- bool is_at(int x, int y) {
- return x > x_pos - Fonts::chalk_large.get_width(_("Yes"))
- && x < x_pos + int(button_surface.get_width())
- && y > y_pos && y < y_pos + int(button_surface.get_height());
- }
-
- void on_click()
- {
- Sound::PingusSound::play_sound ("yipee");
- manager->exit ();
- }
-
- void on_pointer_enter()
- {
- SurfaceButton::on_pointer_enter();
- Sound::PingusSound::play_sound ("tick");
- }
-};
-
-class ExitMenuNoButton : public GUI::SurfaceButton
-{
-private:
- PingusMenuManager* manager;
-public:
- ExitMenuNoButton(PingusMenuManager* m)
- : GUI::SurfaceButton(Display::get_width()/2 + 80, Display::get_height()/2
+ 15,
- ResDescriptor("core/menu/exit_button_normal"),
- ResDescriptor("core/menu/exit_button_pressed"),
- ResDescriptor("core/menu/exit_button_hover")),
- manager(m)
- {
- }
-
- void draw(DrawingContext& gc) {
- SurfaceButton::draw(gc);
- gc.print_right(Fonts::chalk_large, Display::get_width()/2 + 80,
- Display::get_height()/2 + 15, _("No"));
- }
-
- bool is_at(int x, int y) {
- return x > x_pos - Fonts::chalk_large.get_width(_("No"))
- && x < x_pos + int(button_surface.get_width())
- && y > y_pos && y < y_pos + int(button_surface.get_height());
- }
-
- void on_click() {
- Sound::PingusSound::play_sound ("yipee");
- manager->pop_menu();
- }
-
- void on_pointer_enter()
- {
- SurfaceButton::on_pointer_enter();
- Sound::PingusSound::play_sound ("tick");
- }
-};
-
-ExitMenu::ExitMenu(PingusMenuManager* manager_)
- : PingusSubMenu(manager_)
-{
- gui_manager->add(new ExitMenuYesButton(manager));
- gui_manager->add(new ExitMenuNoButton(manager));
-
- sur = Sprite("core/menu/exit_menu");
-}
-
-ExitMenu::~ExitMenu()
-{
-}
-
-bool
-ExitMenu::draw(DrawingContext& gc)
-{
- //gc.draw_fillrect (0, 0, Display::get_width (), Display::get_height (),
- //0, 0, 0, 0.5);
- gc.draw(sur, Vector2i(gc.get_width()/2 - sur.get_width()/2,
- gc.get_height()/2 - sur.get_height()/2));
- gc.print_center(Fonts::chalk_large, gc.get_width()/2, gc.get_height()/2 -
70, _("Exit Pingus?"));
- PingusSubMenu::draw(gc);
- return true;
-}
-
-/* EOF */
Deleted: trunk/pingus/src/exit_menu.hpp
===================================================================
--- trunk/pingus/src/exit_menu.hpp 2008-07-08 09:41:52 UTC (rev 3739)
+++ trunk/pingus/src/exit_menu.hpp 2008-07-08 09:48:01 UTC (rev 3740)
@@ -1,44 +0,0 @@
-// Pingus - A free Lemmings clone
-// Copyright (C) 2000 Ingo Ruhnke <address@hidden>
-//
-// This program is free software: you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation, either version 3 of the License, or
-// (at your option) any later version.
-//
-// This program is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this program. If not, see <http://www.gnu.org/licenses/>.
-
-#ifndef HEADER_PINGUS_EXIT_MENU_HPP
-#define HEADER_PINGUS_EXIT_MENU_HPP
-
-#include "pingus_sub_menu.hpp"
-
-
-class PingusMenuManager;
-
-class ExitMenu : public PingusSubMenu
-{
-private:
- Sprite sur;
-
-public:
- ExitMenu (PingusMenuManager* manager);
- ~ExitMenu ();
-
- bool draw (DrawingContext& gc);
-
-private:
- ExitMenu (const ExitMenu&);
- ExitMenu& operator= (const ExitMenu&);
-};
-
-
-#endif
-
-/* EOF */
Modified: trunk/pingus/src/pingus_main.cpp
===================================================================
--- trunk/pingus/src/pingus_main.cpp 2008-07-08 09:41:52 UTC (rev 3739)
+++ trunk/pingus/src/pingus_main.cpp 2008-07-08 09:48:01 UTC (rev 3740)
@@ -657,7 +657,7 @@
else // start a normal game
{
pout(PINGUS_DEBUG_LOADING) << "starting normal game" << std::endl;
- screen_manager.push_screen(new PingusMenuManager());
+ screen_manager.push_screen(new PingusMenu());
pout(PINGUS_DEBUG_LOADING) << "done: starting normal game" << std::endl;
}
Modified: trunk/pingus/src/pingus_menu.cpp
===================================================================
--- trunk/pingus/src/pingus_menu.cpp 2008-07-08 09:41:52 UTC (rev 3739)
+++ trunk/pingus/src/pingus_menu.cpp 2008-07-08 09:48:01 UTC (rev 3740)
@@ -36,8 +36,7 @@
#include "editor/editor_screen.hpp"
#include "credits.hpp"
-PingusMenu::PingusMenu (PingusMenuManager* m)
- : PingusSubMenu (m)
+PingusMenu::PingusMenu()
{
is_init = false;
@@ -69,23 +68,57 @@
logo = Sprite("core/misc/logo");
+ int w = Display::get_width();
+ int h = Display::get_height();
+
+ Sprite layer1("core/menu/layer1");
+ Sprite layer2("core/menu/layer2");
+ Sprite layer3("core/menu/layer3");
+ Sprite layer4("core/menu/layer4");
+ Sprite layer5("core/menu/layer5");
+
+ // We only need to scale the background main menu images if the screen
+ // resolution is not default
+ if (w != default_screen_width && h != default_screen_height)
+ {
+ layer1.scale(w, 185 * h / default_screen_height);
+ layer2.scale(w, 362 * h / default_screen_height);
+ layer3.scale(w, 306 * h / default_screen_height);
+ layer4.scale(w, 171 * h / default_screen_height);
+ layer5.scale(302 * w / default_screen_width, 104 * h /
default_screen_height);
+
+ background.add_layer(layer1, 0, 0, 12, 0);
+ background.add_layer(layer2, 0, 150 * (float)h / default_screen_height,
25, 0);
+ background.add_layer(layer3, 0, 200 * (float)h / default_screen_height,
50, 0);
+ background.add_layer(layer4, 0, 429 * (float)h / default_screen_height,
100, 0);
+ background.add_layer(layer5, 0, 500 * (float)h / default_screen_height,
200, 0);
+ }
+ else
+ {
+ background.add_layer(layer1, 0, 0, 12, 0);
+ background.add_layer(layer2, 0, 150, 25, 0);
+ background.add_layer(layer3, 0, 200, 50, 0);
+ background.add_layer(layer4, 0, 429, 100, 0);
+ background.add_layer(layer5, 0, 500, 200, 0);
+ }
+
help = _("..:: Ctrl-g: mouse grab :: F10: fps counter :: F11:
fullscreen :: F12: screenshot ::..");
}
+PingusMenu::~PingusMenu()
+{
+}
+
void
PingusMenu::show_credits()
{
ScreenManager::instance()->push_screen(new Credits());
}
-PingusMenu::~PingusMenu()
-{
-}
-
void
PingusMenu::do_quit()
{
- get_manager()->show_exit_menu ();
+ ScreenManager::instance ()->pop_screen ();
}
void
@@ -133,12 +166,20 @@
void
PingusMenu::on_escape_press ()
{
- get_manager()->show_exit_menu ();
+ //FIXME: get_manager()->show_exit_menu ();
}
void
-PingusMenu::draw_foreground(DrawingContext& gc)
+PingusMenu::draw_background(DrawingContext& gc)
{
+ background.draw(gc);
+
+ gc.draw_fillrect(0,
+ Display::get_height () - 26,
+ Display::get_width (),
+ Display::get_height (),
+ Color(0, 0, 0, 255));
+
if (gc.get_height() == 480)
{
gc.draw(logo,
@@ -174,24 +215,6 @@
}
void
-PingusMenu::load(const std::string &file, const std::string &filemask)
-{
- // Level
- if (filemask == ".pingus")
- do_contrib(file);
- // Worldmap
- else if (filemask == ".worldmap")
- do_start(file);
- manager->pop_menu();
-}
-
-void
-PingusMenu::cancel()
-{
- manager->pop_menu();
-}
-
-void
PingusMenu::on_click(MenuButton* button)
{
if (button == start_button)
@@ -221,7 +244,7 @@
void
PingusMenu::update(float delta)
{
- //text_scroll_offset += 100.0f * delta;
+ background.update(delta);
}
/* EOF */
Modified: trunk/pingus/src/pingus_menu.hpp
===================================================================
--- trunk/pingus/src/pingus_menu.hpp 2008-07-08 09:41:52 UTC (rev 3739)
+++ trunk/pingus/src/pingus_menu.hpp 2008-07-08 09:48:01 UTC (rev 3740)
@@ -21,6 +21,7 @@
#include "fonts.hpp"
#include "pingus_sub_menu.hpp"
#include "layer_manager.hpp"
+#include "screen/gui_screen.hpp"
class SurfaceButton;
class GameDelta;
@@ -30,8 +31,8 @@
} // namespace GUI
class MenuButton;
-
-class PingusMenu : public PingusSubMenu
+
+class PingusMenu : public GUIScreen
{
public:
bool is_init;
@@ -40,6 +41,7 @@
float text_scroll_offset;
private:
+ LayerManager background;
Sprite logo;
MenuButton* start_button;
@@ -55,14 +57,8 @@
void do_start(const std::string &filename);
void do_edit();
- /** Use this to load the level or worldmap */
- virtual void load(const std::string &file, const std::string &filemask);
-
- /** Cancels the file dialog box */
- virtual void cancel();
-
public:
- PingusMenu (PingusMenuManager* m);
+ PingusMenu();
~PingusMenu();
void on_click(MenuButton* button);
@@ -72,15 +68,14 @@
void do_contrib(const std::string&);
void on_escape_press ();
- void draw_foreground(DrawingContext& gc);
+ void draw_background(DrawingContext& gc);
void update(float delta);
private:
PingusMenu (const PingusMenu&);
PingusMenu& operator= (const PingusMenu&);
};
-
-
+
#endif
/* EOF */
Deleted: trunk/pingus/src/pingus_menu_manager.cpp
===================================================================
--- trunk/pingus/src/pingus_menu_manager.cpp 2008-07-08 09:41:52 UTC (rev
3739)
+++ trunk/pingus/src/pingus_menu_manager.cpp 2008-07-08 09:48:01 UTC (rev
3740)
@@ -1,164 +0,0 @@
-// Pingus - A free Lemmings clone
-// Copyright (C) 2000 Ingo Ruhnke <address@hidden>
-//
-// This program is free software: you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation, either version 3 of the License, or
-// (at your option) any later version.
-//
-// This program is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-//
-// 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 <iostream>
-#include "screen/screen_manager.hpp"
-#include "sound/sound.hpp"
-#include "resource.hpp"
-#include "pingus_menu_manager.hpp"
-#include "globals.hpp"
-
-
-PingusMenuManager* PingusMenuManager::instance_ = 0;
-
-PingusMenuManager::PingusMenuManager ()
- : mainmenu (this),
- exitmenu (this)
-{
- int w = Display::get_width();
- int h = Display::get_height();
-
- Sprite layer1("core/menu/layer1");
- Sprite layer2("core/menu/layer2");
- Sprite layer3("core/menu/layer3");
- Sprite layer4("core/menu/layer4");
- Sprite layer5("core/menu/layer5");
-
- // We only need to scale the background main menu images if the screen
- // resolution is not default
- if (w != default_screen_width && h != default_screen_height)
- {
- layer1.scale(w, 185 * h / default_screen_height);
- layer2.scale(w, 362 * h / default_screen_height);
- layer3.scale(w, 306 * h / default_screen_height);
- layer4.scale(w, 171 * h / default_screen_height);
- layer5.scale(302 * w / default_screen_width, 104 * h /
default_screen_height);
-
- background.add_layer(layer1, 0, 0, 12, 0);
- background.add_layer(layer2, 0, 150 * (float)h / default_screen_height,
25, 0);
- background.add_layer(layer3, 0, 200 * (float)h / default_screen_height,
50, 0);
- background.add_layer(layer4, 0, 429 * (float)h / default_screen_height,
100, 0);
- background.add_layer(layer5, 0, 500 * (float)h / default_screen_height,
200, 0);
- }
- else
- {
- background.add_layer(layer1, 0, 0, 12, 0);
- background.add_layer(layer2, 0, 150, 25, 0);
- background.add_layer(layer3, 0, 200, 50, 0);
- background.add_layer(layer4, 0, 429, 100, 0);
- background.add_layer(layer5, 0, 500, 200, 0);
- }
-
- push_menu (&mainmenu);
-}
-
-PingusMenuManager::~PingusMenuManager ()
-{
-}
-
-bool
-PingusMenuManager::draw (DrawingContext& gc)
-{
- background.draw(gc);
-
- gc.draw_fillrect(0,
- Display::get_height () - 26,
- Display::get_width (),
- Display::get_height (),
- Color(0, 0, 0, 255));
-
- for (MenuStackIter i = menu_stack.begin (); i != menu_stack.end (); ++i)
- (*i)->draw(gc);
-
- return true;
-}
-
-void
-PingusMenuManager::update(float delta)
-{
- background.update(delta);
- menu_stack.back()->update(delta);
-}
-
-void
-PingusMenuManager::update(const Input::Event& event)
-{
- menu_stack.back()->update(event);
-}
-
-void
-PingusMenuManager::set_menu (PingusSubMenu * menu)
-{
- pop_menu ();
- push_menu (menu);
-}
-
-void
-PingusMenuManager::push_menu (PingusSubMenu * menu)
-{
- menu_stack.push_back (menu);
-}
-
-void
-PingusMenuManager::pop_menu ()
-{
- if (!menu_stack.empty ())
- menu_stack.pop_back();
-}
-
-PingusSubMenu *
-PingusMenuManager::current_menu ()
-{
- if (!menu_stack.empty ())
- {
- MenuStackRIter i = menu_stack.rbegin ();
- if (! *i)
- std::cout << "PingusMenuManager: Error: current_menu is " << *i <<
std::endl;
- return *i;
- }
- else
- {
- std::cout << "PingusMenuManager: Error: MenuStack empty!" << std::endl;
- return 0;
- }
-}
-
-void
-PingusMenuManager::show_exit_menu ()
-{
- push_menu(&exitmenu);
-}
-
-void
-PingusMenuManager::exit ()
-{
- //std::cout << "poping PingusMenuManager" << std::endl;
- ScreenManager::instance ()->pop_screen ();
-}
-
-void
-PingusMenuManager::on_startup()
-{
- Sound::PingusSound::play_music("pingus-1.it");
-}
-
-void
-PingusMenuManager::resize(const Size& size)
-{
-
-}
-
-/* EOF */
Deleted: trunk/pingus/src/pingus_menu_manager.hpp
===================================================================
--- trunk/pingus/src/pingus_menu_manager.hpp 2008-07-08 09:41:52 UTC (rev
3739)
+++ trunk/pingus/src/pingus_menu_manager.hpp 2008-07-08 09:48:01 UTC (rev
3740)
@@ -1,78 +0,0 @@
-// Pingus - A free Lemmings clone
-// Copyright (C) 2000 Ingo Ruhnke <address@hidden>
-//
-// This program is free software: you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation, either version 3 of the License, or
-// (at your option) any later version.
-//
-// This program is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this program. If not, see <http://www.gnu.org/licenses/>.
-
-#ifndef HEADER_PINGUS_PINGUS_MENU_MANAGER_HPP
-#define HEADER_PINGUS_PINGUS_MENU_MANAGER_HPP
-
-#include "layer_manager.hpp"
-#include "exit_menu.hpp"
-#include "pingus_menu.hpp"
-
-class PingusSubMenu;
-
-class PingusMenuManager : public Screen
-{
-private:
- static PingusMenuManager* instance_;
- /** Menu stack. the menu on top is .end (), the bottom menu .begin () */
- std::vector<PingusSubMenu *> menu_stack;
- typedef std::vector<PingusSubMenu *>::iterator MenuStackIter;
- typedef std::vector<PingusSubMenu *>::reverse_iterator MenuStackRIter;
-
-public:
- /* Menu's FIXME: These shouldn't get exported to the outsite,
- instead only handles (enum's) should be visible */
- PingusMenu mainmenu;
- LayerManager background;
- ExitMenu exitmenu;
-
- PingusMenuManager();
- virtual ~PingusMenuManager();
-
- bool draw(DrawingContext& gc);
- void update(float delta);
- void update(const Input::Event& event);
-
- /// Exit the menu manager (which means to exit the while() loop in display
())
- void show_exit_menu ();
-
- void exit ();
-
- PingusSubMenu * current_menu();
-
- // Replace the current menu with a new one
- void set_menu (PingusSubMenu * menu);
-
- /** Remove the current menu and fall back to the last one.
- This is used for yes/no dialoges and such things. */
- void pop_menu();
-
- /** Add's a new menu to the menu stack. This is used for yes/no
- dialoges and such things.*/
- void push_menu (PingusSubMenu * menu);
-
- void on_startup();
-
- void resize(const Size& size);
-private:
- PingusMenuManager (const PingusMenuManager&);
- PingusMenuManager& operator= (const PingusMenuManager&);
-};
-
-
-#endif
-
-/* EOF */
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Pingus-CVS] r3740 - in trunk/pingus: . src src/components,
grumbel at BerliOS <=