[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Pingus-CVS] r3787 - trunk/pingus/src/editor
From: |
grumbel at BerliOS |
Subject: |
[Pingus-CVS] r3787 - trunk/pingus/src/editor |
Date: |
Fri, 11 Jul 2008 14:57:54 +0200 |
Author: grumbel
Date: 2008-07-11 14:57:54 +0200 (Fri, 11 Jul 2008)
New Revision: 3787
Removed:
trunk/pingus/src/editor/context_menu.cpp
trunk/pingus/src/editor/context_menu.hpp
Log:
Removed unused files
Deleted: trunk/pingus/src/editor/context_menu.cpp
===================================================================
--- trunk/pingus/src/editor/context_menu.cpp 2008-07-11 12:53:35 UTC (rev
3786)
+++ trunk/pingus/src/editor/context_menu.cpp 2008-07-11 12:57:54 UTC (rev
3787)
@@ -1,240 +0,0 @@
-// Pingus - A free Lemmings clone
-// Copyright (C) 2007 Jason Green <address@hidden>,
-// 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 "context_menu.hpp"
-#include "level_objs.hpp"
-#include "viewport.hpp"
-#include "editor_screen.hpp"
-#include "../gui/gui_manager.hpp"
-#include "../string_util.hpp"
-#include "../fonts.hpp"
-
-namespace Editor {
-
-// Determine which actions are available for these objects
-ContextMenu::ContextMenu(std::vector<LevelObj*> o, Vector2i p, Viewport* vp,
bool base_menu)
- : objs(o),
- viewport(vp),
- pos(p),
- selected_action_offset(0),
- displayed_child(0),
- item_height(Fonts::verdana11.get_height())
-{
- if (base_menu)
- {
- // Create all available child menus
- width = 110;
- show = true;
- create_child_menus();
- }
- else
- {
- width = 200;
- show = false;
- }
-
- total_height = item_height * actions.size();
-}
-
-
-ContextMenu::~ContextMenu()
-{
-}
-
-
-// Keep track of where the mouse is for highlighting
-void
-ContextMenu::on_pointer_move(int x, int y)
-{
- mouse_at.x = x;
- mouse_at.y = y;
-
- selected_action_offset = (unsigned)((mouse_at.y - pos.y) / item_height);
-}
-
-void
-ContextMenu::draw(DrawingContext &gc)
-{
- if (show)
- {
- // Draw the box
- gc.draw_fillrect(pos.x, pos.y, pos.x + width, pos.y + total_height,
- Color(211,211,211,100));
- // Draw the border
- gc.draw_rect(pos.x, pos.y, pos.x + width, pos.y + total_height,
- Color(0,0,0));
- // Draw the highlighted action if the mouse is in the box
- if (hover)
- {
- gc.draw_fillrect(pos.x, pos.y + selected_action_offset *
- item_height, pos.x + width, pos.y +
(selected_action_offset + 1) * item_height,
- Color(128,128,128,150));
- }
-
- // Draw the action names
- for (unsigned i = 0; i < actions.size(); i++)
- gc.print_left(Fonts::verdana11, pos.x, pos.y +
- (i * item_height), actions[i].friendly_name);
- }
-}
-
-bool
-ContextMenu::is_at(int x, int y)
-{
- if (show)
- return (x > pos.x && x < pos.x + (int)width &&
- y > pos.y && y < pos.y + (int)total_height);
- else
- return false;
-}
-
-void
-ContextMenu::on_primary_button_click(int x, int y)
-{
- if (!actions[selected_action_offset].child)
- {
- for (unsigned i = 0; i < objs.size(); i++)
- {
- switch (actions[selected_action_offset].modifier)
- {
- case (REMOVE) :
- objs[i]->remove();
- break;
- case (ROTATE) :
-
objs[i]->set_modifier(actions[selected_action_offset].parameter);
- break;
- case (SET_OWNER) :
-
objs[i]->set_owner(StringUtil::to<int>(actions[selected_action_offset].parameter));
- break;
- case (SET_DIRECTION) :
-
objs[i]->set_direction(actions[selected_action_offset].parameter);
- break;
- case (SET_Z_POS) :
- objs[i]->set_pos(Vector3f(objs[i]->get_pos().x,
objs[i]->get_pos().y,
-
(float)StringUtil::to<int>(actions[selected_action_offset].parameter)));
- objs[i]->set_orig_pos(objs[i]->get_pos());
- break;
- default :
- break;
- }
- }
- // FIXME: should be handled differently: viewport->remove_context_menu();
- }
-}
-
-void
-ContextMenu::on_secondary_button_click(int x, int y)
-{
- // Does the same as the primary button
- on_primary_button_click(x, y);
-}
-
-void
-ContextMenu::create_child_menus()
-{
- // Create Remove button - available to all objects
- actions.push_back(ContextItem("Remove", "", REMOVE, 0));
-
- // Determine which actions are available to the selected objects
- unsigned available_attribs = 0xffff;
- for (unsigned i = 0; i < (unsigned)objs.size(); i++)
- available_attribs = available_attribs & objs[i]->get_attribs();
-
- ContextMenu* menu;
- if (available_attribs & CAN_ROTATE)
- {
- menu = new ContextMenu(objs, Vector2i(pos.x + width, pos.y), viewport,
false);
- viewport->get_screen()->get_gui_manager()->add(menu, true);
- menu->add_action(ContextItem("0 degrees", "ROT0", ROTATE, 0));
- menu->add_action(ContextItem("90 Degrees", "ROT90", ROTATE, 0));
- menu->add_action(ContextItem("180 Degrees", "ROT180", ROTATE, 0));
- menu->add_action(ContextItem("270 Degrees", "ROT270", ROTATE, 0));
- menu->add_action(ContextItem("0 Degrees + Flip", "ROT0FLIP", ROTATE, 0));
- menu->add_action(ContextItem("90 Degrees + Flip", "ROT90FLIP", ROTATE,
0));
- menu->add_action(ContextItem("180 Degrees + Flip", "ROT180FLIP", ROTATE,
0));
- menu->add_action(ContextItem("270 Degrees + Flip", "ROT270FLIP", ROTATE,
0));
- add_action(ContextItem("Rotate >", "", ROTATE, menu));
- }
- if (available_attribs & HAS_OWNER)
- {
- menu = new ContextMenu(objs, Vector2i(pos.x + width, pos.y), viewport,
false);
- viewport->get_screen()->get_gui_manager()->add(menu, true);
- menu->add_action(ContextItem("0", "0", SET_OWNER, 0));
- menu->add_action(ContextItem("1", "1", SET_OWNER, 0));
- menu->add_action(ContextItem("2", "2", SET_OWNER, 0));
- menu->add_action(ContextItem("3", "3", SET_OWNER, 0));
- add_action(ContextItem("Set Owner >", "", SET_OWNER, menu));
- }
- if (available_attribs & HAS_DIRECTION)
- {
- menu = new ContextMenu(objs, Vector2i(pos.x + width, pos.y), viewport,
false);
- viewport->get_screen()->get_gui_manager()->add(menu, true);
- menu->add_action(ContextItem("Left", "left", SET_DIRECTION, 0));
- menu->add_action(ContextItem("Right", "right", SET_DIRECTION, 0));
- menu->add_action(ContextItem("Misc.", "misc", SET_DIRECTION, 0));
- add_action(ContextItem("Direction >", "", SET_DIRECTION, menu));
- }
- menu = new ContextMenu(objs, Vector2i(pos.x + width, pos.y), viewport,
false);
- viewport->get_screen()->get_gui_manager()->add(menu, true);
- menu->add_action(ContextItem("-50", "-50", SET_Z_POS, 0));
- menu->add_action(ContextItem("-25", "-25", SET_Z_POS, 0));
- menu->add_action(ContextItem("0", "0", SET_Z_POS, 0));
- menu->add_action(ContextItem("25", "25", SET_Z_POS, 0));
- menu->add_action(ContextItem("50", "50", SET_Z_POS, 0));
- add_action(ContextItem("Set Z Pos. >", "", SET_Z_POS, menu));
-
- // TODO - Add more menu options here
-}
-
-void
-ContextMenu::add_action(ContextItem item)
-{
- actions.push_back(item);
- total_height += item_height;
-}
-
-void
-ContextMenu::display(bool should_display)
-{
- show = should_display;
- if (!show && displayed_child)
- displayed_child->display(false);
-}
-
-void
-ContextMenu::update(float delta)
-{
- UNUSED_ARG(delta);
-
- if (displayed_child != actions[selected_action_offset].child)
- {
- if (displayed_child)
- {
- displayed_child->display(false);
- displayed_child = 0;
- }
- if (actions[selected_action_offset].child)
- {
- displayed_child = actions[selected_action_offset].child;
- displayed_child->display(true);
- }
- }
-}
-
-} // Editor namespace
-
-/* EOF */
Deleted: trunk/pingus/src/editor/context_menu.hpp
===================================================================
--- trunk/pingus/src/editor/context_menu.hpp 2008-07-11 12:53:35 UTC (rev
3786)
+++ trunk/pingus/src/editor/context_menu.hpp 2008-07-11 12:57:54 UTC (rev
3787)
@@ -1,123 +0,0 @@
-// Pingus - A free Lemmings clone
-// Copyright (C) 2007 Jason Green <address@hidden>,
-// 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_EDITOR_CONTEXT_MENU_HPP
-#define HEADER_PINGUS_EDITOR_CONTEXT_MENU_HPP
-
-#include <vector>
-#include <string>
-#include "../math/vector2i.hpp"
-#include "../gui/component.hpp"
-
-namespace Editor {
-
-class LevelObj;
-class Viewport;
-class ContextMenu;
-
-typedef enum ItemModifier { REMOVE, ROTATE, SET_OWNER, SET_DIRECTION,
- STRETCH, SET_Z_POS };
-
-class ContextItem {
-public:
- std::string friendly_name;
- std::string parameter;
- ItemModifier modifier;
- ContextMenu* child;
-
-public:
- ContextItem(std::string friendly_name_, std::string parameter_, ItemModifier
mod,
- ContextMenu* child_menu)
- : friendly_name(friendly_name_),
- parameter(parameter_),
- modifier(mod),
- child(child_menu)
- { }
-};
-
-class ContextMenu : public GUI::Component {
-private:
- /** Creates the child menu structure and detemines which actions are
available */
- void create_child_menus();
-
- /** Level objects to be affected by this menu */
- std::vector<LevelObj*> objs;
-
- /** Viewport to which this menu belongs */
- Viewport* viewport;
-
- /** List of actions available in this menu */
- std::vector<ContextItem> actions;
-
- /** Where the mouse is located */
- Vector2i mouse_at;
-
- /** Location of context menu */
- Vector2i pos;
-
- /** Is the mouse over the menu? */
- bool hover;
-
- /** Should this be showing? */
- bool show;
-
- /** The offset into actions vector of the currently highlighted action */
- unsigned selected_action_offset;
-
- /** Currently displayed child menu (if any) */
- ContextMenu* displayed_child;
-
- /** Height of a single action */
- unsigned item_height;
-
- unsigned total_height;
- unsigned width;
-
-public:
- // Constructor
- ContextMenu (std::vector<LevelObj*>, Vector2i p, Viewport* v, bool base_menu
= true);
-
- // Desctructor
- ~ContextMenu ();
-
- /** Add an action to the list */
- void add_action(ContextItem item);
-
- void display (bool should_display);
-
- /// GUI Component Functions
- bool is_at(int x, int y);
- void draw (DrawingContext& gc);
- void update (float delta);
- void on_pointer_move (int x, int y);
- void on_primary_button_click(int x, int y);
- void on_secondary_button_click(int x, int y);
- void on_pointer_enter () { hover = true; }
- void on_pointer_leave () { hover = false; }
-
-private:
- ContextMenu ();
- ContextMenu (const ContextMenu&);
- ContextMenu& operator= (const ContextMenu&);
-
-};
-
-} // Editor namespace
-
-#endif
-
-/* EOF */
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Pingus-CVS] r3787 - trunk/pingus/src/editor,
grumbel at BerliOS <=