[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Pingus-CVS] r3340 - in trunk/pingus: . data/data data/images/core/menu
From: |
grumbel at BerliOS |
Subject: |
[Pingus-CVS] r3340 - in trunk/pingus: . data/data data/images/core/menu src src/actions src/editor |
Date: |
Sat, 27 Oct 2007 09:08:54 +0200 |
Author: grumbel
Date: 2007-10-27 09:08:51 +0200 (Sat, 27 Oct 2007)
New Revision: 3340
Added:
trunk/pingus/data/images/core/menu/marker2.png
Removed:
trunk/pingus/src/file_dialog.cpp
trunk/pingus/src/file_dialog.hpp
trunk/pingus/src/file_dialog_item.cpp
trunk/pingus/src/file_dialog_item.hpp
trunk/pingus/src/file_dialog_listener.hpp
Modified:
trunk/pingus/SConstruct
trunk/pingus/TODO
trunk/pingus/data/data/core.res
trunk/pingus/data/images/core/menu/marker.png
trunk/pingus/src/actions/bridger.cpp
trunk/pingus/src/editor/editor_screen.cpp
trunk/pingus/src/level_menu.cpp
trunk/pingus/src/level_menu.hpp
trunk/pingus/src/pingus_menu.cpp
trunk/pingus/src/pingus_menu_manager.hpp
trunk/pingus/src/system.hpp
Log:
- removed filedialog
- some more levelset menu stuff
Modified: trunk/pingus/SConstruct
===================================================================
--- trunk/pingus/SConstruct 2007-10-27 06:15:33 UTC (rev 3339)
+++ trunk/pingus/SConstruct 2007-10-27 07:08:51 UTC (rev 3340)
@@ -109,8 +109,6 @@
'src/collision_mask.cpp',
'src/exit_menu.cpp',
-'src/file_dialog.cpp',
-'src/file_dialog_item.cpp',
'src/file_reader.cpp',
'src/sexpr_file_reader.cpp',
'src/sexpr_file_writer.cpp',
Modified: trunk/pingus/TODO
===================================================================
--- trunk/pingus/TODO 2007-10-27 06:15:33 UTC (rev 3339)
+++ trunk/pingus/TODO 2007-10-27 07:08:51 UTC (rev 3340)
@@ -12,6 +12,8 @@
- make sure that the game still runs after install.sh
+- remove test levelset before release
+
- check NEWS, README, INSTALL.*
Stuff to do at all times:
@@ -95,15 +97,13 @@
- Water Glitch: the water on the minimap changes color after the colmap is
altered or the first time
-- bridge tile isn't flipped in bridger
-
- Levels: All levels lack name and description
- check all entrances are properly done
- check that number of pingus and number to save are adjusted
- check that actions are limited
- add name and descriptions
-halloween1-grumbel.pingus - circle save - finished - needs testing (easy)
+halloween1-grumbel.pingus - circle save - finished - needs testing (easy) -
demonstrates a Faller bug
halloween2-grumbel.pingus - rescue by jump - finished - needs testing (easy)
halloween3-grumbel.pingus - digg tunnel - finished - needs testing (medium)
halloween4-grumbel.pingus - wall bomb - finished - needs testing (easy/medium)
Modified: trunk/pingus/data/data/core.res
===================================================================
--- trunk/pingus/data/data/core.res 2007-10-27 06:15:33 UTC (rev 3339)
+++ trunk/pingus/data/data/core.res 2007-10-27 07:08:51 UTC (rev 3340)
@@ -352,6 +352,10 @@
(image-file "../images/core/menu/marker.png"))
(sprite
+ (name "marker2")
+ (image-file "../images/core/menu/marker2.png"))
+
+ (sprite
(name "filedialog")
(image-file "../images/core/menu/filedialog.png"))
Modified: trunk/pingus/data/images/core/menu/marker.png
===================================================================
(Binary files differ)
Added: trunk/pingus/data/images/core/menu/marker2.png
===================================================================
(Binary files differ)
Property changes on: trunk/pingus/data/images/core/menu/marker2.png
___________________________________________________________________
Name: svn:mime-type
+ image/png
Modified: trunk/pingus/src/actions/bridger.cpp
===================================================================
--- trunk/pingus/src/actions/bridger.cpp 2007-10-27 06:15:33 UTC (rev
3339)
+++ trunk/pingus/src/actions/bridger.cpp 2007-10-27 07:08:51 UTC (rev
3340)
@@ -46,9 +46,9 @@
walk_sprite.load (Direction::RIGHT, Resource::load_sprite("pingus/player" +
pingu->get_owner_str() + "/bridger_walk/right"));
- build_sprite.load (Direction::LEFT, Resource::load_sprite("pingus/player" +
+ build_sprite.load(Direction::LEFT, Resource::load_sprite("pingus/player" +
pingu->get_owner_str() + "/bridger/left"));
- build_sprite.load (Direction::RIGHT, Resource::load_sprite("pingus/player" +
+ build_sprite.load(Direction::RIGHT, Resource::load_sprite("pingus/player" +
pingu->get_owner_str() + "/bridger/right"));
}
@@ -227,7 +227,7 @@
}
else
{
- WorldObj::get_world()->put(brick_r,
+ WorldObj::get_world()->put(brick_l,
static_cast<int>(pingu->get_pos().x - 10),
static_cast<int>(pingu->get_pos().y),
Groundtype::GP_BRIDGE);
Modified: trunk/pingus/src/editor/editor_screen.cpp
===================================================================
--- trunk/pingus/src/editor/editor_screen.cpp 2007-10-27 06:15:33 UTC (rev
3339)
+++ trunk/pingus/src/editor/editor_screen.cpp 2007-10-27 07:08:51 UTC (rev
3340)
@@ -29,7 +29,6 @@
#include "../res_descriptor.hpp"
#include "../resource.hpp"
#include "../fonts.hpp"
-#include "../file_dialog.hpp"
#include "gettext.h"
#include "file_dialog.hpp"
#include "../path_manager.hpp"
Deleted: trunk/pingus/src/file_dialog.cpp
===================================================================
--- trunk/pingus/src/file_dialog.cpp 2007-10-27 06:15:33 UTC (rev 3339)
+++ trunk/pingus/src/file_dialog.cpp 2007-10-27 07:08:51 UTC (rev 3340)
@@ -1,475 +0,0 @@
-// $Id$
-//
-// Pingus - A free Lemmings clone
-// Copyright (C) 2005 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 <algorithm>
-
-#include "gettext.h"
-#include "system.hpp"
-#include "pingus_menu_manager.hpp"
-#include "resource.hpp"
-#include "gui/surface_button.hpp"
-#include "gui/gui_manager.hpp"
-#include "gui/input_box.hpp"
-#include "sound/sound.hpp"
-#include "file_dialog.hpp"
-#include "file_dialog_item.hpp"
-#include "file_dialog_listener.hpp"
-
-#define CANCEL_TEXT _("Cancel")
-
-const int DIR_UP = 0;
-const int DIR_DOWN = 1;
-
-class FileDialogOkButton : public GUI::SurfaceButton
-{
-private:
- FileDialog* file_dialog;
- std::string label;
- bool is_hidden;
-
-public:
- FileDialogOkButton (FileDialog *f, std::string l)
- : GUI::SurfaceButton(Display::get_width()/2 + 230,
- Display::get_height()/2 + 160,
- ResDescriptor("core/menu/exit_button_normal"),
- ResDescriptor("core/menu/exit_button_pressed"),
- ResDescriptor("core/menu/exit_button_hover")),
- file_dialog(f),
- label (l),
- is_hidden(true)
- {
- }
-
- void draw (DrawingContext& gc) {
- if (!is_hidden)
- {
- SurfaceButton::draw(gc);
- gc.print_right(Fonts::chalk_large, Display::get_width()/2 + 230,
- Display::get_height()/2 + 160, label);
- }
- }
-
- bool is_at(int x, int y) {
- return x > x_pos - Fonts::chalk_large.get_width(label)
- && x < x_pos + int(button_surface.get_width())
- && y > y_pos && y < y_pos + int(button_surface.get_height());
-}
-
- void on_click()
-{
- if (!is_hidden)
- {
- Sound::PingusSound::play_sound ("yipee");
- file_dialog->ok_pressed();
- }
-}
-
-void on_pointer_enter()
-{
- if (!is_hidden)
- {
- SurfaceButton::on_pointer_enter();
- Sound::PingusSound::play_sound ("tick");
- }
-}
-
-void hide() { is_hidden = true; }
-void show() { is_hidden = false; }
-
-};
-
-class FileDialogCancelButton : public GUI::SurfaceButton
-{
-private:
- FileDialog* file_dialog;
-
-public:
- FileDialogCancelButton (FileDialog* f)
- : GUI::SurfaceButton(Display::get_width()/2 - 280 +
Fonts::chalk_large.get_width(CANCEL_TEXT),
- Display::get_height()/2 + 160,
- ResDescriptor("core/menu/exit_button_normal"),
- ResDescriptor("core/menu/exit_button_pressed"),
- ResDescriptor("core/menu/exit_button_hover")),
- file_dialog (f)
- {
- }
-
- void draw (DrawingContext& gc) {
- SurfaceButton::draw(gc);
- gc.print_left(Fonts::chalk_large, Display::get_width()/2 - 280,
- Display::get_height()/2 + 160, CANCEL_TEXT);
- }
-
- bool is_at(int x, int y) {
- return x > x_pos - Fonts::chalk_large.get_width(CANCEL_TEXT)
- && 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");
- file_dialog->cancel_pressed();
- }
-
- void on_pointer_enter()
- {
- SurfaceButton::on_pointer_enter();
- Sound::PingusSound::play_sound ("tick");
- }
-};
-
-class FileDialogScrollButton : public GUI::Component
-{
-private:
- /** FileDialog box to this which button is assigned */
- FileDialog* file_dialog;
-
- /** Where the image is located */
- Vector2i pos;
-
- /** Image used for the scroll button */
- Sprite sprite;
-
- /** 0 for Up, 1 for Down */
- int direction;
-
- /** Show it or not */
- bool is_hidden;
-
- bool hover;
-
-public:
- FileDialogScrollButton (FileDialog* f, int d, int height_offset)
- : file_dialog(f),
- pos(Vector2i(Display::get_width()/2 + 210,
- Display::get_height()/2 + height_offset)),
- direction(d),
- is_hidden(false),
- hover(false)
- {
- std::string str_direction = d==0 ? "up" : "down";
- sprite = Resource::load_sprite("core/menu/" + str_direction + "_arrow");
- }
-
- void draw (DrawingContext& gc) {
- if (!is_hidden)
- {
- gc.draw(sprite, pos);
- if (hover)
- gc.draw_rect(pos.x, pos.y, pos.x + sprite.get_width(),
- pos.y + sprite.get_height(), Color(255,255,255,150));
- }
- }
-
- void on_primary_button_click(int x, int y)
- {
- file_dialog->scroll(direction);
- }
-
- void on_pointer_enter() { hover = true; }
- void on_pointer_leave() { hover = false; }
-
- bool is_at(int x, int y)
- {
- if (is_hidden)
- return false;
- return (x > pos.x && x < pos.x + sprite.get_width()
- && y > pos.y && y < pos.y + sprite.get_height());
- }
-
- void show() { is_hidden = false; }
- void hide() { is_hidden = true; }
-};
-
-class FileDialogParentFolderButton : public GUI::Component
-{
-private:
- /** FileDialog box to this which button is assigned */
- FileDialog* file_dialog;
-
- /** Where the image is located */
- Vector2i pos;
-
- /** Image used for the parent folder button */
- Sprite sprite;
-
- bool hover;
-
-public:
- FileDialogParentFolderButton (FileDialog* f)
- : file_dialog(f),
- pos(Vector2i(Display::get_width()/2 + 230,
- Display::get_height()/2 - 210)),
- sprite(Resource::load_sprite("core/menu/parent_folder")),
- hover(false)
- {
- }
-
- void draw (DrawingContext& gc) {
- gc.draw(sprite, pos);
- if (hover)
- gc.draw_rect(pos.x, pos.y, pos.x + sprite.get_width(),
- pos.y + sprite.get_height(), Color(255,255,255,150));
- }
-
- void on_primary_button_click(int x, int y)
- {
- FileItem f;
- f.name = "..";
- f.is_directory = true;
- file_dialog->set_selected_file(f);
- }
-
- void on_pointer_enter() { hover = true; }
- void on_pointer_leave() { hover = false; }
-
- bool is_at(int x, int y)
- {
- return (x > pos.x && x < pos.x + sprite.get_width()
- && y > pos.y && y < pos.y + sprite.get_height());
- }
-};
-
-FileDialog::FileDialog (FileDialogListener* listener_,
- const std::string filemask_,
- const std::string searchpath_,
- bool for_load)
- : PingusSubMenu (PingusMenuManager::instance()),
- listener(listener_),
- for_loading(for_load),
- file_mask(filemask_),
- current_path(searchpath_)
-{
- // Initialize the buttons
- ok_button = new FileDialogOkButton(this,
- for_loading ? _("Load") : _("Save"));
-
- up_button = new FileDialogScrollButton(this, DIR_UP, -150);
- down_button = new FileDialogScrollButton(this, DIR_DOWN, 100);
-
- gui_manager->add(ok_button, true);
- gui_manager->add(up_button, true);
- gui_manager->add(down_button, true);
- gui_manager->add(new FileDialogCancelButton(this), true);
- gui_manager->add(new FileDialogParentFolderButton(this), true);
-
- // FIXME: Ugly - hardcoded values for items in file dialog. Should be
dynamic.
- // Create 8 FileDialogItems and add them to the gui_manager.
- int center_x = Display::get_width()/2;
- int center_y = Display::get_height()/2;
-
- inputbox = new GUI::InputBox(450, Vector2i(center_x - 225,
- center_y - 170), "", for_loading);
- gui_manager->add((GUI::Component*)inputbox, true);
-
- file_dialog_items.push_back(new FileDialogItem(this,
- Vector2i(center_x - 280,
center_y - 140)));
- file_dialog_items.push_back(new FileDialogItem(this,
- Vector2i(center_x - 280,
center_y - 70)));
- file_dialog_items.push_back(new FileDialogItem(this,
- Vector2i(center_x - 280,
center_y + 10)));
- file_dialog_items.push_back(new FileDialogItem(this,
- Vector2i(center_x - 280,
center_y + 80)));
- file_dialog_items.push_back(new FileDialogItem(this,
- Vector2i(center_x - 10,
center_y - 140)));
- file_dialog_items.push_back(new FileDialogItem(this,
- Vector2i(center_x - 10,
center_y - 70)));
- file_dialog_items.push_back(new FileDialogItem(this,
- Vector2i(center_x - 10,
center_y + 10)));
- file_dialog_items.push_back(new FileDialogItem(this,
- Vector2i(center_x - 10,
center_y + 80)));
-
- for (std::vector<FileDialogItem*>::const_iterator i =
file_dialog_items.begin();
- i != file_dialog_items.end(); i++)
- gui_manager->add((GUI::Component*)(*i), true);
-
- refresh();
-}
-
-FileDialog::~FileDialog ()
-{
-}
-
-bool FileDialog::draw (DrawingContext& gc)
-{
- gc.draw(sprite, Vector2i(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.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);
-
- PingusSubMenu::draw(gc);
- return true;
-}
-
-void FileDialog::preload ()
-{
- sprite = Resource::load_sprite("core/menu/filedialog");
-}
-
-void FileDialog::refresh ()
-{
- // Clear the current list of files
- 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
- d = System::opendir(current_path, "*");
- for (diter = d.begin(); diter != d.end(); ++diter)
- {
- if ((*diter).name != "." && (*diter).name != ".."
- && (*diter).name != ".svn" && (*diter).type == System::DE_DIRECTORY)
- {
- f.name = (*diter).name;
- f.is_directory = true;
- file_list.push_back(f);
- }
- }
-
- d = System::opendir(current_path, "*" + file_mask);
- for (diter = d.begin(); diter != d.end(); ++diter)
- {
- f.name = (*diter).name;
- f.is_directory = false;
- file_list.push_back(f);
- }
-
- std::sort(file_list.begin(), file_list.end(), &FileItemCompare);
-
- current_offset = 0;
- offset_changed();
-}
-
-// Whenever the list of showing files has changed.
-void FileDialog::offset_changed()
-{
- unsigned j = current_offset;
-
- for (std::vector<FileDialogItem*>::const_iterator i =
file_dialog_items.begin();
- i != file_dialog_items.end(); i++, j++)
- {
- if (j < (unsigned)file_list.size())
- (*i)->set_file(file_list[j]);
- else
- (*i)->hide();
- }
-
- // Show or hide scroll buttons
- if (current_offset == 0)
- up_button->hide();
- else
- up_button->show();
-
- if (current_offset + (unsigned)file_dialog_items.size() <
(unsigned)file_list.size())
- down_button->show();
- else
- down_button->hide();
-}
-
-// Scroll the list up or down.
-void FileDialog::scroll(int direction)
-{
- if (direction == DIR_UP)
- {
- if (current_offset != 0)
- current_offset -= (unsigned)file_dialog_items.size();
- }
- else
- {
- if (current_offset + (unsigned)file_dialog_items.size() <
(unsigned)file_list.size())
- current_offset += (unsigned)file_dialog_items.size();
- }
- offset_changed();
-}
-
-// Set the file and show or hide the OK button.
-void FileDialog::set_selected_file(FileItem f)
-{
- current_file = f;
- if (current_file.name != "")
- ok_button->show();
- else
- ok_button->hide();
-
- inputbox->set_string(current_file.name.substr(0,
-
current_file.name.length()-file_mask.length()));
-
- if (current_file.is_directory)
- ok_pressed();
-}
-
-void FileDialog::ok_pressed()
-{
- // If it's a directory, change to it.
- if (current_file.is_directory)
- {
- if (current_file.name != "..")
- {
- current_path += current_file.name + "/";
- }
- else
- {
- size_t index = current_path.size() > 1 ? current_path.size() - 2 :
std::string::npos;
- size_t pos = current_path.find_last_of('/', index);
- if (pos != std::string::npos)
- current_path = current_path.substr(0, pos + 1);
- else
- current_path.clear();
- }
- refresh();
- ok_button->hide();
- }
- else
- {
- if (for_loading)
- listener->load(current_path + current_file.name, file_mask);
- else
- listener->save(current_path + current_file.name, file_mask);
- }
-}
-
-void FileDialog::cancel_pressed()
-{
- listener->cancel();
-}
-
-void FileDialog::update(const GameDelta &delta)
-{
- PingusSubMenu::update(delta);
-
- // FIXME: Ugly busy polling
- if (!for_loading)
- if (inputbox->get_string() != current_file.name)
- {
- FileItem f;
- f.friendly_name = inputbox->get_string();
- f.name = f.friendly_name + file_mask;
- f.is_directory = false;
- set_selected_file(f);
- }
-}
-
-
-/* EOF */
Deleted: trunk/pingus/src/file_dialog.hpp
===================================================================
--- trunk/pingus/src/file_dialog.hpp 2007-10-27 06:15:33 UTC (rev 3339)
+++ trunk/pingus/src/file_dialog.hpp 2007-10-27 07:08:51 UTC (rev 3340)
@@ -1,140 +0,0 @@
-// $Id$
-//
-// Pingus - A free Lemmings clone
-// Copyright (C) 2005 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_FILE_DIALOG_HXX
-#define HEADER_PINGUS_FILE_DIALOG_HXX
-
-#include <vector>
-#include <string>
-#include "pingus_sub_menu.hpp"
-
-
-class Vector;
-class FileDialogItem;
-class FileDialogOkButton;
-class FileDialogScrollButton;
-class FileDialogListener;
-
-namespace GUI {
-class InputBox;
-}
-
-struct FileItem {
- std::string name;
- std::string short_name;
- std::string friendly_name;
- bool is_accessible;
- bool is_finished;
- bool is_directory;
-};
-
-/** Sorting function for FileItem's */
-inline bool FileItemCompare (const FileItem& a, const FileItem& b)
-{
- if (a.is_directory == b.is_directory)
- return (a.name < b.name);
- else
- return (a.is_directory);
-}
-
-class FileDialog : public PingusSubMenu
-{
-private:
- Sprite sprite;
-
- /** The OK button - need to be able to hide and show it */
- FileDialogOkButton* ok_button;
-
- /** Scroll buttons */
- FileDialogScrollButton* up_button;
- FileDialogScrollButton* down_button;
-
- /** The owner of this file dialog */
- FileDialogListener* listener;
-
- /** Box to take the keyboard input */
- GUI::InputBox* inputbox;
-
- /** Should this dialog box be used for loading? True for load, false for
saving */
- bool for_loading;
-
- /** Mask for which files to display (*.pingus, *.xml, etc.) */
- std::string file_mask;
-
- /** Current path that is being displayed */
- std::string current_path;
-
- /** Offset in the file_list that is the index of the first file/folder shown
*/
- unsigned current_offset;
-
- /** Current file that is selected */
- FileItem current_file;
-
- /** List of directories & files in the current folder */
- std::vector<FileItem> file_list;
-
- /** List of files in the directory */
- std::vector<FileDialogItem*> file_dialog_items;
-
- /** Scroll the displayed file list */
- void offset_changed();
-
-public:
- FileDialog (FileDialogListener* listener_,
- const std::string filemask_,
- const std::string searchpath_,
- const bool for_load = true);
-
- ~FileDialog ();
-
- bool draw (DrawingContext& gc);
- void update(const GameDelta &delta);
-
- void preload();
-
- /** Refresh the file list */
- void refresh();
-
- /** Return the current path in the dialog */
- std::string get_path() const { return current_path; }
-
- /** Return the file mask */
- std::string get_file_mask() const { return file_mask; }
-
- /** Sets the currently selected file name */
- void set_selected_file(FileItem f);
-
- /** The Ok button has been pressed - either Save or Load this file */
- void ok_pressed();
-
- /** The Cancel button has been pressed - close the box */
- void cancel_pressed();
-
- /** Need to scroll the list of files if possible */
- void scroll(int direction);
-
-private:
- FileDialog (const FileDialog&);
- FileDialog& operator= (const FileDialog&);
-};
-
-
-#endif
-
-/* EOF */
Deleted: trunk/pingus/src/file_dialog_item.cpp
===================================================================
--- trunk/pingus/src/file_dialog_item.cpp 2007-10-27 06:15:33 UTC (rev
3339)
+++ trunk/pingus/src/file_dialog_item.cpp 2007-10-27 07:08:51 UTC (rev
3340)
@@ -1,206 +0,0 @@
-// $Id$
-//
-// Pingus - A free Lemmings clone
-// Copyright (C) 2005 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 <sstream>
-#include "pingus_error.hpp"
-#include "file_dialog_item.hpp"
-#include "file_dialog.hpp"
-#include "math/vector3f.hpp"
-#include "fonts.hpp"
-#include "resource.hpp"
-#include "gettext.h"
-#include "stat_manager.hpp"
-#include "savegame_manager.hpp"
-#include "savegame.hpp"
-#include "worldmap/manager.hpp"
-#include "worldmap/metamap.hpp"
-
- // Only Constructor
- FileDialogItem::FileDialogItem(FileDialog* f, Vector2i p)
- : mouse_over(false),
- is_hidden(true),
- file_dialog(f),
- pos(p),
- sprite(Resource::load_sprite("core/misc/404sprite"))
- {
- }
-
- /** Set the current file assigned to this button */
- void
- FileDialogItem::set_file(FileItem f)
- {
- file_item = f;
- is_hidden = false;
- // Load sprite based on file (folder icon, level screenshot,
or generic)
- if (file_item.is_directory)
- {
- file_item.is_accessible = true;
- sprite = Resource::load_sprite("core/menu/folder");
- }
- else
- {
- // FIXME: Load thumbnail specific to this level
- sprite =
Resource::load_sprite("core/menu/default_level");
- file_item.short_name.clear();
- file_item.friendly_name.clear();
- file_item.is_accessible = true;
- file_item.is_finished = false;
- file_info.clear();
- status.clear();
-
- // Load information about this file if possible.
- FileReader reader =
FileReader::parse(file_dialog->get_path() + file_item.name);
- if (reader.get_name() == "pingus-level")
- {
- FileReader head;
- int difficulty = 0;
- std::ostringstream ostr;
- if (reader.read_section("head", head))
- {
- head.read_string("levelname",
file_item.friendly_name);
- if (file_item.friendly_name.empty())
- file_item.friendly_name =
get_filename();
- else
- file_item.friendly_name =
_(file_item.friendly_name);
- head.read_int("difficulty", difficulty);
- ostr << difficulty;
- file_info = _("Difficulty: ") +
ostr.str();
- file_item.is_accessible = true;
- Savegame* sg =
SavegameManager::instance()->get(file_item.friendly_name); // FIXME: doesn't
won't work
- if (sg && sg->get_status() ==
Savegame::FINISHED) {
- status = _("Finished!");
- file_item.is_finished = true;
- }
- else {
- status = _("Not finished!");
- file_item.is_finished = false;
- }
- }
- }
- else if (reader.get_name() == "pingus-worldmap")
- {
- FileReader head;
- if (reader.read_section("head", head))
- {
- head.read_string("name",
file_item.friendly_name);
- head.read_string("short-name",
file_item.short_name);
- head.read_string("description",
file_info);
-
- // Get player's status for this worldmap
- status = _("Not Finished");
- if (StatManager::instance()->get_bool(
- file_item.short_name +
"-accessible", file_item.is_accessible))
- {
- if (!file_item.is_accessible)
- status = _("Not
Accessible");
- }
- if (StatManager::instance()->get_bool(
- file_item.short_name +
"-finished", file_item.is_finished))
- {
- if (file_item.is_finished)
- status = _("Finished!");
- }
- file_item.friendly_name =
_(file_item.friendly_name);
- file_info = _(file_info);
- }
- }
- // Have to limit the size of the printed name
- file_item.friendly_name =
file_item.friendly_name.substr(0, 23);
- } // else it's a file, not a directory
- } //set_file()
-
- bool
- FileDialogItem::is_at(int x, int y)
- {
- if (is_hidden)
- return false;
- return (x > pos.x && x < pos.x + sprite.get_width()
- && y > pos.y && y < pos.y + sprite.get_height());
- }
-
- void
- FileDialogItem::draw (DrawingContext& gc)
- {
- if (!is_hidden)
- {
- // Draw thumbnail
- gc.draw(sprite, pos);
-
- if (!mouse_over || file_item.is_directory)
- {
- // Draw title
- gc.print_left(Fonts::pingus_small, pos.x +
sprite.get_width(),
- pos.y, get_filename());
- }
- else
- {
- // If mouse over, draw a quick info box about
the file item
- if (file_item.is_directory)
- {
- gc.draw_rect(pos.x, pos.y, pos.x +
sprite.get_width(),
- pos.y + sprite.get_height(),
Color(255,255,255,150));
- }
- else // It's a file
- {
- // Determine which color to draw the
background rectangle.
- Color color;
- if (file_item.is_accessible)
- {
- if (file_item.is_finished)
- color =
Color(123,123,0);////Color::azure;
- else
- color =
Color(123,0,222); ////Color::aqua;
- }
- else
- color = Color(255,0,0);
- gc.draw_fillrect(pos.x+50, pos.y,
pos.x+270, pos.y+75, color);
-
- // Draw level or worldmap information.
- gc.print_left(Fonts::pingus_small,
pos.x+50, pos.y, file_item.friendly_name);
- gc.print_left(Fonts::pingus_small,
pos.x+50, pos.y+25, file_info);
- gc.print_left(Fonts::pingus_small,
pos.x+50, pos.y+50, status);
- }
- }
- }
- }
-
- void
- FileDialogItem::on_primary_button_click (int x, int y)
- {
- if (file_item.is_accessible)
- file_dialog->set_selected_file(file_item);
- }
-
- void
- FileDialogItem::hide()
- {
- file_item.name = "";
- is_hidden = true;
- }
-
- std::string
- FileDialogItem::get_filename() const
- {
- if (file_item.is_directory)
- return file_item.name;
- else
- return file_item.name.substr(0, file_item.name.size() -
file_dialog->get_file_mask().size());
- }
-
-/* EOF */
Deleted: trunk/pingus/src/file_dialog_item.hpp
===================================================================
--- trunk/pingus/src/file_dialog_item.hpp 2007-10-27 06:15:33 UTC (rev
3339)
+++ trunk/pingus/src/file_dialog_item.hpp 2007-10-27 07:08:51 UTC (rev
3340)
@@ -1,82 +0,0 @@
-// $Id$
-//
-// Pingus - A free Lemmings clone
-// Copyright (C) 2005 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_FILE_DIALOG_ITEM_HXX
-#define HEADER_PINGUS_FILE_DIALOG_ITEM_HXX
-
-#include "gui/component.hpp"
-#include "math/vector2i.hpp"
-#include "sprite.hpp"
-#include "file_dialog.hpp"
-
-
-/** Class representing a clickable object in a File Dialog (a Directory, Level,
- or Worldmap */
-class FileDialogItem : GUI::Component
-{
-private:
- bool mouse_over;
- bool is_hidden;
-
- /** Extra info about this file - differs based on file type
(difficulty, etc.) */
- std::string file_info;
- std::string status;
-
- FileDialog* file_dialog;
- Vector2i pos;
-
- /** This file_item name will change based on the current file list */
- FileItem file_item;
-
- /** This sprite will change based on the currently displayed file */
- Sprite sprite;
-
-public:
- // Only Constructor
- FileDialogItem(FileDialog* f, Vector2i p) ;
-
- /** Set the current file assigned to this button */
- void set_file(FileItem f);
-
- /** Get the cleaned up file name (no extension) */
- std::string get_filename() const;
-
- bool is_at(int x, int y);
-
- void draw (DrawingContext& gc);
-
- void hide ();
-
- void on_primary_button_click (int x, int y);
-
- /** Emmitted when pointer enters the region of the component */
- void on_pointer_enter () { mouse_over = true; }
-
- /** Emmitted when pointer leaves the region of the component */
- void on_pointer_leave () { mouse_over = false; }
-
-private:
- FileDialogItem();
- FileDialogItem (const FileDialogItem&);
- FileDialogItem& operator= (const FileDialogItem&);
-}; // FileDialogItem class
-
-#endif
-
-/* EOF */
Deleted: trunk/pingus/src/file_dialog_listener.hpp
===================================================================
--- trunk/pingus/src/file_dialog_listener.hpp 2007-10-27 06:15:33 UTC (rev
3339)
+++ trunk/pingus/src/file_dialog_listener.hpp 2007-10-27 07:08:51 UTC (rev
3340)
@@ -1,36 +0,0 @@
-// $Id$
-//
-// Pingus - A free Lemmings clone
-// Copyright (C) 2005 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_FILE_DIALOG_LISTENER_HXX
-#define HEADER_PINGUS_FILE_DIALOG_LISTENER_HXX
-
-#include <string>
-#include "pingus.hpp"
-
-class FileDialogListener {
-public:
- virtual ~FileDialogListener() {}
- virtual void save(const std::string &file, const std::string &filemask) { }
- virtual void load(const std::string &file, const std::string &filemask) { }
- virtual void cancel() { }
-}; // class FileDialogListener
-
-#endif
-
-/* EOF */
Modified: trunk/pingus/src/level_menu.cpp
===================================================================
--- trunk/pingus/src/level_menu.cpp 2007-10-27 06:15:33 UTC (rev 3339)
+++ trunk/pingus/src/level_menu.cpp 2007-10-27 07:08:51 UTC (rev 3340)
@@ -24,15 +24,25 @@
#include "fonts.hpp"
#include "display/drawing_context.hpp"
#include "option_menu.hpp"
+#include "system.hpp"
+#include "display/display.hpp"
#include "level_menu.hpp"
LevelMenu::LevelMenu()
+ : x_pos((Display::get_width() - 800)/2),
+ y_pos((Display::get_height() - 600)/2)
{
background = Resource::load_sprite("core/menu/filedialog");
ok_button = Resource::load_sprite("core/start/ok");
marker = Resource::load_sprite("core/menu/marker");
+ marker_small = Resource::load_sprite("core/menu/marker2");
- levelsets.push_back(new Levelset(Pathname("levelsets/halloween.levelset",
Pathname::DATA_PATH)));
+ std::string path = Pathname("levelsets", Pathname::DATA_PATH).get_sys_path();
+ System::Directory directory = System::opendir(path, "*.levelset");
+ for(System::Directory::iterator i = directory.begin(); i != directory.end();
++i)
+ {
+ levelsets.push_back(new Levelset(Pathname(path + "/" + i->name,
Pathname::SYSTEM_PATH)));
+ }
}
LevelMenu::~LevelMenu()
@@ -53,30 +63,61 @@
void
LevelMenu::draw_background(DrawingContext& gc)
{
+ gc.push_modelview();
+ gc.translate(x_pos, y_pos);
+
// gc.draw_fillrect(Rect(100, 100, 400, 400), Color(255, 0, 0));
- gc.draw(background, Vector2i(gc.get_width()/2 - background.get_width()/2,
gc.get_height()/2 - background.get_height()/2));
+ gc.draw(background, Vector2i(400 - background.get_width()/2, 300 -
background.get_height()/2));
- gc.print_center(Fonts::chalk_large, gc.get_width()/2, 90, "Contrib Level
Menu");
+ if (0)
+ {
+ gc.print_center(Fonts::chalk_large, 800/2, 90, _("Levelset Menu"));
- int y = 145;
- for(Levelsets::iterator i = levelsets.begin(); i != levelsets.end(); ++i)
+ int y = 145;
+ for(Levelsets::iterator i = levelsets.begin(); i != levelsets.end(); ++i)
+ {
+ if (i == levelsets.begin())
+ gc.draw(marker, 100, y - 20);
+
+ gc.print_left(Fonts::chalk_normal, 120, 0 + y, (*i)->get_title());
+ gc.print_left(Fonts::chalk_small, 140, 25 + y,
(*i)->get_description());
+
+ gc.print_right(Fonts::chalk_normal, 650, 0 + y,
(boost::format("Completion: %1%%%") % (*i)->get_completion()).str());
+ gc.print_right(Fonts::chalk_small, 650, 45 + y, (boost::format("%1%
levels") % (*i)->get_level_count()).str());
+
+ //gc.draw(ok_button, 620, y);
+
+ y += 90;
+ }
+ //gc.draw(ok_button, 610, 145);
+ }
+ else
{
- gc.print_left(Fonts::chalk_normal, 120, 0 + y, (*i)->get_title());
- gc.print_left(Fonts::chalk_small, 140, 25 + y, (*i)->get_description());
+ Levelset* levelset = *levelsets.begin();
- gc.print_right(Fonts::chalk_normal, 650, 0 + y,
(boost::format("Completion: %1%%%") % (*i)->get_completion()).str());
- gc.print_right(Fonts::chalk_small, 650, 45 + y, (boost::format("%1%
levels") % (*i)->get_level_count()).str());
+ gc.print_center(Fonts::chalk_large, 800/2, 90, _(levelset->get_title()));
- y += 90;
+ gc.print_left(Fonts::chalk_normal, 120, 145, "Levelname");
+ gc.print_right(Fonts::chalk_normal, 660, 145, "Completed");
+ int y = 185;
+ for(int i = 0; i < levelset->get_level_count(); ++i)
+ {
+ if (i == 0)
+ gc.draw(marker_small, 100, y-4);
+
+ std::string level = levelset->get_level(i);
+ gc.print_left(Fonts::chalk_small, 120, y, level);
+ gc.print_right(Fonts::chalk_small, 660, y, "[x]");
+ y += 32;
+ }
}
- gc.draw(marker, 100, 136);
- //gc.draw(ok_button, 610, 145);
+ gc.pop_modelview();
}
void
LevelMenu::on_pointer_move (int x, int y)
{
-
+
}
void
Modified: trunk/pingus/src/level_menu.hpp
===================================================================
--- trunk/pingus/src/level_menu.hpp 2007-10-27 06:15:33 UTC (rev 3339)
+++ trunk/pingus/src/level_menu.hpp 2007-10-27 07:08:51 UTC (rev 3340)
@@ -28,9 +28,13 @@
class LevelMenu : public GUIScreen
{
private:
+ int x_pos;
+ int y_pos;
+
Sprite background;
Sprite ok_button;
Sprite marker;
+ Sprite marker_small;
typedef std::vector<Levelset*> Levelsets;
Levelsets levelsets;
Modified: trunk/pingus/src/pingus_menu.cpp
===================================================================
--- trunk/pingus/src/pingus_menu.cpp 2007-10-27 06:15:33 UTC (rev 3339)
+++ trunk/pingus/src/pingus_menu.cpp 2007-10-27 07:08:51 UTC (rev 3340)
@@ -36,7 +36,6 @@
#include "plf_res_mgr.hpp"
#include "path_manager.hpp"
#include "pathname.hpp"
-#include "file_dialog.hpp"
#include "editor/editor_screen.hpp"
#include "credits.hpp"
Modified: trunk/pingus/src/pingus_menu_manager.hpp
===================================================================
--- trunk/pingus/src/pingus_menu_manager.hpp 2007-10-27 06:15:33 UTC (rev
3339)
+++ trunk/pingus/src/pingus_menu_manager.hpp 2007-10-27 07:08:51 UTC (rev
3340)
@@ -23,7 +23,6 @@
#include "layer_manager.hpp"
#include "exit_menu.hpp"
#include "pingus_menu.hpp"
-#include "file_dialog.hpp"
class PingusSubMenu;
Modified: trunk/pingus/src/system.hpp
===================================================================
--- trunk/pingus/src/system.hpp 2007-10-27 06:15:33 UTC (rev 3339)
+++ trunk/pingus/src/system.hpp 2007-10-27 07:08:51 UTC (rev 3340)
@@ -36,6 +36,7 @@
static int verbose;
static std::string default_email;
static std::string default_username;
+
public:
enum FileType { DE_DIRECTORY, DE_FILE };
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Pingus-CVS] r3340 - in trunk/pingus: . data/data data/images/core/menu src src/actions src/editor,
grumbel at BerliOS <=