[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Pingus-CVS] CVS: Games/Pingus/src menu_button.cxx,NONE,1.1 menu_button.
From: |
torangan |
Subject: |
[Pingus-CVS] CVS: Games/Pingus/src menu_button.cxx,NONE,1.1 menu_button.hxx,NONE,1.1 Makefile.am,1.137,1.138 pingus_menu.cxx,1.12,1.13 surface_button.cxx,1.22,NONE surface_button.hxx,1.12,NONE |
Date: |
18 Mar 2003 17:24:57 -0000 |
Update of /usr/local/cvsroot/Games/Pingus/src
In directory dark:/tmp/cvs-serv16611
Modified Files:
Makefile.am pingus_menu.cxx
Added Files:
menu_button.cxx menu_button.hxx
Removed Files:
surface_button.cxx surface_button.hxx
Log Message:
renamed /src/surface_button.[ch]xx --> /src/menu_button.[ch]xx
--- NEW FILE: menu_button.cxx ---
// $Id: menu_button.cxx,v 1.1 2003/03/18 17:24:55 torangan Exp $
//
// Pingus - A free Lemmings clone
// Copyright (C) 1999 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 2
// 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, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include <ClanLib/Display/Display/display.h>
#include <ClanLib/Display/Font/font.h>
#include "globals.hxx"
#include "debug.hxx"
#include "sound/sound.hxx"
#include "pingus_resource.hxx"
#include "pingus_menu_manager.hxx"
#include "credits.hxx"
#include "editor/editor.hxx"
#include "theme_selector.hxx"
#include "menu_button.hxx"
#include "gui/screen_manager.hxx"
#include "worldmap/manager.hxx"
#include "my_gettext.hxx"
using EditorNS::Editor;
SurfaceButton::SurfaceButton ()
{
font = PingusResource::load_font("Fonts/pingus_small", "fonts");
font_large = PingusResource::load_font("Fonts/pingus", "fonts");
mouse_over = false;
pressed = false;
//std::cout << "Generating font cache: " << std::flush;
// We print all available letters, so that they are in the cache
//font->print_left (0,0, "!\"#$%&'()*+,-./0123456789:;<=>address@hidden|}~");
//font_large->print_left (0,0,
"!\"#$%&'()*+,-./0123456789:;<=>address@hidden|}~");
//std::cout << "done" << std::endl;
}
SurfaceButton::~SurfaceButton ()
{
}
void
SurfaceButton::draw (GraphicContext& gc)
{
if (mouse_over && !pressed)
{
font->print_center(CL_Display::get_width() / 2,
CL_Display::get_height() - 20,
desc.c_str());
surface_p.put_screen(x_pos - surface_p.get_width()/2,
y_pos - surface_p.get_height()/2);
if (line2.empty())
{
font_large->print_center(x_pos + 32,
y_pos - 32 - font_large->get_height()/2,
line1.c_str());
}
else
{
font_large->print_center(x_pos + 32, y_pos - 32 -
font_large->get_height(),
line1.c_str());
font_large->print_center(x_pos + 32, y_pos - 32,
line2.c_str());
}
}
else if (mouse_over && pressed)
{
float shrink = 0.9f;
font->print_center(CL_Display::get_width() / 2,
CL_Display::get_height() - 20,
desc.c_str());
surface_p.put_screen(static_cast<int>(x_pos - surface_p.get_width()/2 *
shrink),
static_cast<int>(y_pos - surface_p.get_height()/2 *
shrink),
shrink, shrink);
if (line2.empty())
{
font_large->print_center(x_pos + 32,
y_pos - 32 - font_large->get_height()/2,
line1.c_str());
}
else
{
font_large->print_center(x_pos + 32, y_pos - 32 -
font_large->get_height(),
line1.c_str());
font_large->print_center(x_pos + 32, y_pos - 32,
line2.c_str());
}
}
else
{
surface_p.put_screen(x_pos - surface_p.get_width()/2,
y_pos - surface_p.get_height()/2);
}
UNUSED_ARG(gc);
}
void
SurfaceButton::update (float delta)
{
UNUSED_ARG(delta);
}
void
SurfaceButton::on_pointer_enter ()
{
mouse_over = true;
PingusSound::play_sound ("tick");
//std::cout << "X: " << this << "enter" << std::endl;
}
void
SurfaceButton::on_pointer_leave ()
{
//std::cout << "X: " << this << "leave" << std::endl;
mouse_over = false;
}
void
SurfaceButton::on_pointer_press ()
{
pressed = true;
}
void
SurfaceButton::on_pointer_release ()
{
pressed = false;
}
bool
SurfaceButton::is_at(int x, int y)
{
assert (surface);
return (x > x_pos - int(surface.get_width()) / 2
&& x < x_pos + int(surface.get_width()) / 2
&& y > y_pos - int(surface.get_height()) / 2
&& y < y_pos + int(surface.get_height()) / 2);
}
///////////////////////////////////////////////
CreditButton::CreditButton (PingusMenu* menu_)
: menu(menu_)
{
// x_pos = CL_Display::get_width() * 500 / 640;
// y_pos = CL_Display::get_height() * 420 / 480;
x_pos = CL_Display::get_width() * 126 / 640;
y_pos = CL_Display::get_height() * 369 / 480;
// desc["en"] = "..:: Starts the level you played at last ::..";
desc = _("..:: The people who brought this game to you ::..");
//desc["de"] = "..:: Wer hat den dieses Spiel verbrochen...? ::..";
line1 = _("Credits");
//line1["de"] = "Credits";
surface = PingusResource::load_surface("menu/ice_off", "core");
surface_p = PingusResource::load_surface("menu/credits_on", "core");
// surface = PingusResource::load_surface("NewButtons/credits_off",
"menu");
//surface = PingusResource::load_surface("Buttons/play", "menu");
//surface_p = PingusResource::load_surface("Buttons/play_p", "menu");
}
CreditButton::~CreditButton ()
{
}
void
CreditButton::on_click ()
{
std::cout << "Pushing credits screen" << std::endl;
ScreenManager::instance()->push_screen (Credits::instance(), false);
}
///////////////////////////////////////////////
OptionsButton::OptionsButton (PingusMenu* menu_)
: menu(menu_)
{
// x_pos = CL_Display::get_width() * 150 / 640; //150;
// y_pos = CL_Display::get_height() * 330 / 480; //330;
x_pos = CL_Display::get_width() * 516 / 640; //150;
y_pos = CL_Display::get_height() * 113 / 480; //330;
desc = _("..:: Takes you to the options menu ::..");
// desc["de"] = "..:: Einstellungen und Mogeleien ::..";
line1 = _("Options");
//line1["de"] = "Einstellungen";
surface = PingusResource::load_surface("menu/ice_off", "core");
// surface = PingusResource::load_surface("NewButtons/options_off",
"menu");
surface_p = PingusResource::load_surface("menu/options_on", "core");
// surface = PingusResource::load_surface("Buttons/options", "menu");
// surface_p = PingusResource::load_surface("Buttons/options_p", "menu");
}
OptionsButton::~OptionsButton ()
{
}
void
OptionsButton::on_click()
{
//option_menu.display();
//menu->get_manager ()->set_menu (&menu->get_manager ()->optionmenu);
perr (PINGUS_DEBUG_GUI) << "Option menu currently disabled" << std::endl;
}
///////////////////////////////////////////////
QuitButton::QuitButton(PingusMenu* m)
: menu (m)
{
// x_pos = CL_Display::get_width() * 500 / 640;
// y_pos = CL_Display::get_height() * 320 / 480;
x_pos = CL_Display::get_width() * 516 / 640;
y_pos = CL_Display::get_height() * 369 / 480;
desc = _("..:: Bye, bye ::..");
//desc["de"] = "..:: Auf Wiedersehen ::..";
line1 = _("Exit");
//line1["de"] = "Ausgang";
// surface = PingusResource::load_surface("Buttons/quit", "menu");
// surface_p = PingusResource::load_surface("Buttons/quit_p", "menu");
// surface = PingusResource::load_surface("NewButtons/exit_off", "menu");
surface = PingusResource::load_surface("menu/ice_off", "core");
surface_p = PingusResource::load_surface("menu/exit_on", "core");
}
QuitButton::~QuitButton()
{
}
void
QuitButton::on_click()
{
std::cout << "QuitButton: do exit" << std::endl;
PingusSound::play_sound ("goodidea");
menu->get_manager ()->show_exit_menu ();
}
///////////////////////////////////////////////
LoadButton::LoadButton()
{
x_pos = CL_Display::get_width() * 226 / 640;
y_pos = CL_Display::get_height() * 482 / 480;
surface = PingusResource::load_surface("menu/load", "core");
surface_p = PingusResource::load_surface("menu/load_p", "core");
}
LoadButton::~LoadButton()
{
}
void LoadButton::on_click()
{
/* std::string levelfile;
levelfile = file.select(pXXXus_datadir, "*.plf");
if (!levelfile.empty()) {
PingusGame game;
game.start(levelfile);
}*/
}
EditorButton::EditorButton (PingusMenu* menu_)
: menu(menu_)
{
// x_pos = CL_Display::get_width() * 335 / 640;
// y_pos = CL_Display::get_height() * 370 / 480;
x_pos = CL_Display::get_width() * 126 / 640;
y_pos = CL_Display::get_height() * 113 / 480;
desc = _("..:: Launch the level editor ::..");
//desc["de"] = "..:: Den Level Editor starten ::..";
line1 = _("Create a");
line2 = _("Level");
//line1["de"] = "Level";
//line2["de"] = "Editor";
// surface = PingusResource::load_surface("Buttons/editor", "menu");
// surface_p = PingusResource::load_surface("Buttons/editor_p", "menu");
// surface = PingusResource::load_surface("NewButtons/ice_off", "menu");
surface = PingusResource::load_surface("menu/ice_off", "core");
surface_p = PingusResource::load_surface("menu/create_on", "core");
}
EditorButton::~EditorButton ()
{
}
void
EditorButton::load_level (const std::string& str)
{
Editor::instance ()->load_level (str);
}
void
EditorButton::on_click()
{
ScreenManager::instance()->push_screen (Editor::instance(), false);
}
StoryButton::StoryButton (PingusMenu* menu_)
: menu(menu_)
{
// x_pos = CL_Display::get_width() * 150 / 640;
// y_pos = CL_Display::get_height() * 430 / 480;
x_pos = CL_Display::get_width() * 321 / 640;
y_pos = CL_Display::get_height() * 241 / 480;
desc = _("..:: Lets you select a world to start ::..");
//desc["de"] = "..:: Such dir eine Welt zum beginnen aus ::..";
line1 = _("Start");
// surface = PingusResource::load_surface("Buttons/worlds", "menu");
// surface_p = PingusResource::load_surface("Buttons/worlds_p", "menu");
surface = PingusResource::load_surface("menu/ice_off", "core");
// surface = PingusResource::load_surface("NewButtons/play_off", "menu");
surface_p = PingusResource::load_surface("menu/play_on", "core");
}
StoryButton::~StoryButton () {}
void
StoryButton::on_click ()
{
PingusSound::play_sound ("letsgo");
ScreenManager::instance()->push_screen(WorldMapNS::WorldMapManager::instance
());
}
ThemeButton::ThemeButton (PingusMenu* menu_)
: menu(menu_)
{
x_pos = CL_Display::get_width() * 321 / 640;
y_pos = CL_Display::get_height() * 100 / 480;
desc = _("..:: Start a contrib level ::..");
line1 = _("Contrib");
surface = PingusResource::load_surface("menu/ice_off", "core");
surface_p = PingusResource::load_surface("menu/play_on", "core");
}
void
ThemeButton::on_click ()
{
PingusSound::play_sound ("letsgo");
ThemeSelector theme_selector;
theme_selector.display();
}
#if 0
MultiplayerButton::MultiplayerButton (PingusMenu* menu_)
: menu(menu_)
{
x_pos = CL_Display::get_width() * 320 / 640;
y_pos = CL_Display::get_height() * 369 / 480;
desc = _("..:: Multiplayer Modes... experimental stuff ::..");
line1 = _("Multi");
surface = PingusResource::load_surface("menu/ice_off", "core");
surface_p = PingusResource::load_surface("menu/multi_on", "core");
}
MultiplayerButton::~MultiplayerButton ()
{
}
void
MultiplayerButton::on_click ()
{
multiplayer_config.display ();
}
#endif
/* EOF */
--- NEW FILE: menu_button.hxx ---
// $Id: menu_button.hxx,v 1.1 2003/03/18 17:24:55 torangan Exp $
//
// Pingus - A free Lemmings clone
// Copyright (C) 1999 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 2
// 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, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#ifndef HEADER_PINGUS_SURFACE_BUTTON_HXX
#define HEADER_PINGUS_SURFACE_BUTTON_HXX
#include <string>
#include <ClanLib/Display/Display/surface.h>
#include "gui/component.hxx"
class CL_Font;
class PingusMenu;
/** Framework for menu buttons */
class SurfaceButton : public GUI::Component
{
protected:
CL_Surface surface;
CL_Surface surface_p;
CL_Font* font;
CL_Font* font_large;
int x_pos;
int y_pos;
std::string desc;
std::string line1;
std::string line2;
bool mouse_over;
bool pressed;
public:
SurfaceButton();
virtual ~SurfaceButton();
void draw(GraphicContext& gc);
void update (float delta);
bool is_at (int x, int y);
void on_pointer_enter ();
void on_pointer_leave ();
void on_pointer_press ();
void on_pointer_release ();
void on_primary_button_click (int x, int y) { on_click (); UNUSED_ARG(x);
UNUSED_ARG(y); }
virtual void on_click () =0;
private:
SurfaceButton (const SurfaceButton&);
SurfaceButton& operator= (const SurfaceButton&);
};
class CreditButton : public SurfaceButton
{
private:
PingusMenu* menu;
public:
CreditButton(PingusMenu* menu);
virtual ~CreditButton();
void on_click();
private:
CreditButton (const CreditButton&);
CreditButton& operator= (const CreditButton&);
};
class OptionsButton : public SurfaceButton
{
private:
PingusMenu* menu;
public:
OptionsButton(PingusMenu* menu);
virtual ~OptionsButton();
void on_click();
private:
OptionsButton (const OptionsButton&);
OptionsButton& operator= (const OptionsButton&);
};
class QuitButton : public SurfaceButton
{
private:
PingusMenu* menu;
public:
QuitButton(PingusMenu*);
virtual ~QuitButton();
void on_click();
private:
QuitButton (const QuitButton&);
QuitButton& operator= (const QuitButton&);
};
class LoadButton : public SurfaceButton
{
public:
LoadButton();
virtual ~LoadButton();
void on_click();
private:
LoadButton (const LoadButton&);
LoadButton& operator= (const LoadButton&);
};
class EditorButton : public SurfaceButton
{
private:
PingusMenu* menu;
public:
EditorButton( PingusMenu* menu);
virtual ~EditorButton();
void on_click();
void load_level(const std::string& str);
private:
EditorButton (const EditorButton&);
EditorButton& operator= (const EditorButton&);
};
class StoryButton : public SurfaceButton
{
private:
PingusMenu* menu;
public:
StoryButton(PingusMenu* menu);
~StoryButton();
void on_click();
private:
StoryButton (const StoryButton&);
StoryButton& operator= (const StoryButton&);
};
class ThemeButton : public SurfaceButton
{
private:
PingusMenu* menu;
public:
ThemeButton(PingusMenu* menu);
void on_click();
private:
ThemeButton (const ThemeButton&);
ThemeButton& operator= (const ThemeButton&);
};
#if 0
class MultiplayerButton : public SurfaceButton
{
private:
MultiplayerConfig multiplayer_config;
PingusMenu* menu;
public:
MultiplayerButton(PingusMenu* menu);
virtual ~MultiplayerButton();
void on_click();
private:
MultiplayerButton (const MultiplayerButton&);
MultiplayerButton& operator= (const MultiplayerButton&);
};
#endif
#endif
/* EOF */
Index: Makefile.am
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/Makefile.am,v
retrieving revision 1.137
retrieving revision 1.138
diff -u -d -r1.137 -r1.138
--- Makefile.am 10 Mar 2003 11:29:49 -0000 1.137
+++ Makefile.am 18 Mar 2003 17:24:55 -0000 1.138
@@ -174,6 +174,8 @@
math.hxx \
menu_background.cxx \
menu_background.hxx \
+menu_button.cxx \
+menu_button.hxx \
mover.cxx \
mover.hxx \
multiline_text.cxx \
@@ -256,8 +258,6 @@
sprite.hxx \
string_converter.cxx \
string_converter.hxx \
-surface_button.cxx \
-surface_button.hxx \
system.cxx \
system.hxx \
target_provider.cxx \
Index: pingus_menu.cxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/pingus_menu.cxx,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -d -r1.12 -r1.13
--- pingus_menu.cxx 18 Feb 2003 17:04:13 -0000 1.12
+++ pingus_menu.cxx 18 Mar 2003 17:24:55 -0000 1.13
@@ -17,7 +17,7 @@
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-#include "surface_button.hxx"
+#include "menu_button.hxx"
#include "pingus_resource.hxx"
#include "debug.hxx"
#include "pingus_menu_manager.hxx"
--- surface_button.cxx DELETED ---
--- surface_button.hxx DELETED ---
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Pingus-CVS] CVS: Games/Pingus/src menu_button.cxx,NONE,1.1 menu_button.hxx,NONE,1.1 Makefile.am,1.137,1.138 pingus_menu.cxx,1.12,1.13 surface_button.cxx,1.22,NONE surface_button.hxx,1.12,NONE,
torangan <=