[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Pingus-CVS] r2530 - in trunk: data/data data/images/core/menu src
From: |
jave27 |
Subject: |
[Pingus-CVS] r2530 - in trunk: data/data data/images/core/menu src |
Date: |
Fri, 2 Dec 2005 04:24:59 +0100 |
Author: jave27
Date: 2005-12-02 04:24:09 +0100 (Fri, 02 Dec 2005)
New Revision: 2530
Added:
trunk/data/images/core/menu/parent_folder.png
Modified:
trunk/data/data/core.xml
trunk/src/file_dialog.cxx
Log:
Added a parent folder button to the file dialog.
Modified: trunk/data/data/core.xml
===================================================================
--- trunk/data/data/core.xml 2005-12-02 01:33:04 UTC (rev 2529)
+++ trunk/data/data/core.xml 2005-12-02 03:24:09 UTC (rev 2530)
@@ -135,6 +135,9 @@
<sprite name="folder">
<image file="../images/core/menu/folder.png" />
</sprite>
+ <sprite name="parent_folder">
+ <image file="../images/core/menu/parent_folder.png" />
+ </sprite>
<sprite name="default_level">
<image file="../images/core/menu/default_level.jpg" />
</sprite>
Added: trunk/data/images/core/menu/parent_folder.png
===================================================================
(Binary files differ)
Property changes on: trunk/data/images/core/menu/parent_folder.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Modified: trunk/src/file_dialog.cxx
===================================================================
--- trunk/src/file_dialog.cxx 2005-12-02 01:33:04 UTC (rev 2529)
+++ trunk/src/file_dialog.cxx 2005-12-02 03:24:09 UTC (rev 2530)
@@ -165,12 +165,52 @@
}
};
+ class FileDialogParentFolderButton : public GUI::Component
+ {
+ private:
+ /** FileDialog box to this which button is assigned */
+ FileDialog* file_dialog;
+
+ /** Where the image is located */
+ Vector pos;
+
+ /** Image used for the parent folder button */
+ CL_Sprite sprite;
+
+ public:
+ FileDialogParentFolderButton (FileDialog* f)
+ : file_dialog(f),
+ pos(Vector((float)CL_Display::get_width()/2 + 230,
+ (float)CL_Display::get_height()/2 - 210)),
+
sprite(Resource::load_sprite("core/menu/parent_folder"))
+ {
+ }
+
+ void draw (DrawingContext& gc) {
+ //FIXME: Should also draw a hover box around it when
the mouse is over it.
+ gc.draw(sprite, pos);
+ }
+
+ void on_primary_button_click(int x, int y)
+ {
+ file_dialog->set_selected_file("..");
+ file_dialog->ok_pressed();
+ }
+
+ bool is_at(int x, int y)
+ {
+ return (x > (int)pos.x && x < (int)pos.x +
sprite.get_width()
+ && y > (int)pos.y && y < (int)pos.y +
sprite.get_height());
+ }
+ };
+
FileDialog::FileDialog (PingusMenuManager* manager_, const std::string
filemask_,
const std::string searchpath_, bool for_load)
: PingusSubMenu (manager_),
for_loading(for_load),
file_mask(filemask_),
- current_path(searchpath_)
+ current_path(searchpath_),
+
current_file("Pingus")
{
// Initialize the buttons
ok_button = new FileDialogOkButton(manager, this,
@@ -180,10 +220,8 @@
gui_manager->add(new FileDialogCancelButton(manager), true);
gui_manager->add(new FileDialogScrollButton(this, DIR_DOWN,
100), true);
gui_manager->add(new FileDialogScrollButton(this, DIR_UP,
-150), true);
-
- // FIXME: Add a button to go to the parent folder
+ gui_manager->add(new FileDialogParentFolderButton(this));
-
// FIXME: Ugly - hardcoded values for items in file dialog.
Should be dynamic.
// Create 8 FileDialogItems and add them to the gui_manager.
float center_x = (float)CL_Display::get_width()/2;
@@ -319,7 +357,7 @@
FileDialog::ok_pressed()
{
// If it's a directory, change to it.
- if (file_list[current_file] == true)
+ if (current_file == ".." || file_list[current_file] == true)
{
current_path += current_file + "/";
refresh();
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Pingus-CVS] r2530 - in trunk: data/data data/images/core/menu src,
jave27 <=