[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Pingus-CVS] r2491 - in trunk/src: . editor
From: |
jave27 |
Subject: |
[Pingus-CVS] r2491 - in trunk/src: . editor |
Date: |
Thu, 10 Nov 2005 02:53:09 +0100 |
Author: jave27
Date: 2005-11-10 02:52:16 +0100 (Thu, 10 Nov 2005)
New Revision: 2491
Modified:
trunk/src/editor/editor_panel.cxx
trunk/src/editor/editor_screen.cxx
trunk/src/editor/editor_screen.hxx
trunk/src/editor/editor_viewport.cxx
trunk/src/editor/editor_viewport.hxx
trunk/src/editor/panel_buttons.cxx
trunk/src/editor/panel_buttons.hxx
trunk/src/pingus_menu.cxx
Log:
More level editor stuff.
Modified: trunk/src/editor/editor_panel.cxx
===================================================================
--- trunk/src/editor/editor_panel.cxx 2005-11-09 22:06:55 UTC (rev 2490)
+++ trunk/src/editor/editor_panel.cxx 2005-11-10 01:52:16 UTC (rev 2491)
@@ -60,8 +60,8 @@
void
EditorPanel::draw (DrawingContext& gc)
{
- gc.draw_fillrect(0.0f, 0.0f, (float)CL_Display::get_width(),
- 50.0f, CL_Color::lightgray);
+ gc.draw_fillrect(0, 0, (float)CL_Display::get_width(),
+ 50.0f, CL_Color::lightgray, -50);
}
// Add the button to the vector, set it's position, and add to the gui_manager
Modified: trunk/src/editor/editor_screen.cxx
===================================================================
--- trunk/src/editor/editor_screen.cxx 2005-11-09 22:06:55 UTC (rev 2490)
+++ trunk/src/editor/editor_screen.cxx 2005-11-10 01:52:16 UTC (rev 2491)
@@ -111,9 +111,11 @@
EditorScreen::draw(Pingus::DrawingContext &gc)
{
// Black out screen
- gc.draw_fillrect(0, 0, CL_Display::get_width(),
CL_Display::get_height(),
- CL_Color(0, 0, 0, 255), -10000);
+ gc.draw_fillrect(0, 0, (float)CL_Display::get_width(),
+ (float)CL_Display::get_height(), CL_Color::black, -10000);
gui_manager->draw(gc);
+ gc.print_center(Fonts::pingus_large, (float)(CL_Display::get_width() /
2),
+ (float)(CL_Display::get_height() / 2), "Not yet functional");
return true;
}
Modified: trunk/src/editor/editor_screen.hxx
===================================================================
--- trunk/src/editor/editor_screen.hxx 2005-11-09 22:06:55 UTC (rev 2490)
+++ trunk/src/editor/editor_screen.hxx 2005-11-10 01:52:16 UTC (rev 2491)
@@ -64,7 +64,7 @@
void on_escape_press();
/** Draw the items in the screen */
- virtual bool draw (DrawingContext& gc);
+ bool draw (DrawingContext& gc);
/** Return the gui_manager */
GUI::GUIManager* get_gui_manager() { return gui_manager; }
Modified: trunk/src/editor/editor_viewport.cxx
===================================================================
--- trunk/src/editor/editor_viewport.cxx 2005-11-09 22:06:55 UTC (rev
2490)
+++ trunk/src/editor/editor_viewport.cxx 2005-11-10 01:52:16 UTC (rev
2491)
@@ -38,6 +38,7 @@
(float)(CL_Display::get_height() - 10))),
scene_context(new SceneContext()),
autoscroll(true),
+ translate(0),
state((int)(end_pos.x - start_pos.x), (int)(end_pos.y - start_pos.y))
{
state.set_limit(CL_Rect((int)start_pos.x, (int)start_pos.y,
@@ -64,24 +65,33 @@
void
EditorViewport::draw(DrawingContext &gc)
{
- scene_context->clear();
+ // FIXME: Temporary hack to test translation
+ if (translate == 0)
+ gc.reset_modelview();
+ else if (translate == 3)
+ gc.translate(0, 5);
+ else if (translate == 4)
+ gc.translate(0, -5);
- state.push(*scene_context);
+ //scene_context->clear();
+ //state.push(*scene_context);
// Now, draw all of the objects
// FIXME: Should draw the background over the whole viewport (stretched
or tiled)
if (bg_surface)
- scene_context->color().draw(*bg_surface, start_pos);
+ gc.draw(*bg_surface, start_pos);
else
- scene_context->color().draw_fillrect(start_pos.x, start_pos.y,
end_pos.x, end_pos.y, CL_Color::darkgray);
+ gc.draw_fillrect(start_pos.x, start_pos.y,
+ end_pos.x, end_pos.y, CL_Color::darkgray, -5000);
+ // Added this to test translate scrolling.
+ gc.draw_fillrect(300, 250, 400, 300, CL_Color::white);
- scene_context->color().draw_circle(25, 25, 10, CL_Color::white);
+ //state.pop(*scene_context);
- state.pop(*scene_context);
-
- gc.draw(new SceneContextDrawingRequest(scene_context, 0));
+ //gc.draw(new SceneContextDrawingRequest(scene_context, 0));
+
}
// Returns true if the viewport is at the x,y coordinate
@@ -96,22 +106,35 @@
void
EditorViewport::on_pointer_move(int x, int y)
{
- const int autoscroll_border = 10;
- if (is_at(x, y))
+ mouse_at = Vector(float(x), float(y));
+}
+
+void
+EditorViewport::update(float delta)
+{
+ // Autoscroll if necessary
+ //if (autoscroll)
+ if (0)
{
- // Autoscroll if necessary
- if (x - start_pos.x < autoscroll_border)
- std::cout << "AutoScroll left" << std::endl;
- else if (end_pos.x - x < autoscroll_border)
- std::cout << "AutoScroll right" << std::endl;
- else if (y - start_pos.y < autoscroll_border)
- state.set_pos(state.get_pos() - CL_Pointf(0, 5.0f));
- else if (end_pos.y - y < autoscroll_border)
- state.set_pos(state.get_pos() + CL_Pointf(0, 5.0f));
- //std::cout << "AutoScroll down" << std::endl;
+ const int autoscroll_border = 10;
+ if (autoscroll)
+ {
+ if (mouse_at.x - start_pos.x < autoscroll_border)
+ std::cout << "AutoScroll left" << std::endl;
+ else if (end_pos.x - mouse_at.x < autoscroll_border)
+ std::cout << "AutoScroll right" << std::endl;
+ else if (mouse_at.y - start_pos.y < autoscroll_border)
+ // This should be the right code, I just need
to learn how it works:
+ // state.set_pos(state.get_pos() - CL_Pointf(0,
5.0f));
+ translate = 3;
+ else if (end_pos.y - mouse_at.y < autoscroll_border)
+ //state.set_pos(state.get_pos() + CL_Pointf(0,
5.0f));
+ translate = 4;
+ else
+ translate = 0;
+ }
}
}
-
} // Editor namespace
} // Pingus namespace
Modified: trunk/src/editor/editor_viewport.hxx
===================================================================
--- trunk/src/editor/editor_viewport.hxx 2005-11-09 22:06:55 UTC (rev
2490)
+++ trunk/src/editor/editor_viewport.hxx 2005-11-10 01:52:16 UTC (rev
2491)
@@ -58,6 +58,9 @@
/** Draws all of the objects in the viewport */
void draw(DrawingContext &gc);
+ /** Update information about scrolling, etc. */
+ void update(float delta);
+
/** Returns whether or not the mouse is inside the viewport */
bool is_at(int x, int y);
@@ -72,6 +75,9 @@
GraphicContextState state;
SceneContext* scene_context;
+
+ // FIXME: Temporary hack for translation testing:
+ int translate;
/** The EditorScreen to which this viewport belongs */
EditorScreen* editor;
@@ -90,6 +96,9 @@
/** Whether or not Autoscrolling is turned on */
bool autoscroll;
+
+ /** Where the mouse is right now - used for autoscrolling */
+ Vector mouse_at;
};
} // Editor namespace
Modified: trunk/src/editor/panel_buttons.cxx
===================================================================
--- trunk/src/editor/panel_buttons.cxx 2005-11-09 22:06:55 UTC (rev 2490)
+++ trunk/src/editor/panel_buttons.cxx 2005-11-10 01:52:16 UTC (rev 2491)
@@ -20,6 +20,7 @@
#include <ClanLib/Display/sprite.h>
#include "panel_buttons.hxx"
#include "../display/scene_context.hxx"
+#include "../fonts.hxx"
#include "../resource.hxx"
#include "editor_screen.hxx"
#include "editor_panel.hxx"
@@ -32,7 +33,8 @@
// Constructor
PanelButton::PanelButton(EditorPanel* p) :
- panel(p)
+ panel(p),
+ hover(false)
{
button = Resource::load_sprite("core/editor/button");
button_pressed = Resource::load_sprite("core/editor/button_pressed");
@@ -49,6 +51,12 @@
else
gc.draw(button, pos);
+ // Print the tooltip
+ if (hover)
+ gc.print_left(Fonts::pingus_small, pos.x, pos.y +
(float)get_width(),
+ tooltip, 50);
+
+ // Draw the actual button image
gc.draw(sur, pos);
}
Modified: trunk/src/editor/panel_buttons.hxx
===================================================================
--- trunk/src/editor/panel_buttons.hxx 2005-11-09 22:06:55 UTC (rev 2490)
+++ trunk/src/editor/panel_buttons.hxx 2005-11-10 01:52:16 UTC (rev 2491)
@@ -35,6 +35,10 @@
/** Generic PanelButton class - all buttons in the Editor should inherit from
this */
class PanelButton : public GUI::Component
{
+private:
+ /** Whether or not the mouse is over the button */
+ bool hover;
+
protected:
/** The actual button image */
CL_Sprite sur;
@@ -80,6 +84,12 @@
/** Return true if the button is located at this x,y coordinate */
bool is_at(int x, int y);
+
+ /** Action taken when the mouse enters the button area */
+ virtual void on_pointer_enter () { hover = true; }
+
+ /** Action taken when the mouse leaves the button area */
+ virtual void on_pointer_leave () { hover = false; }
private:
PanelButton (const PanelButton&);
Modified: trunk/src/pingus_menu.cxx
===================================================================
--- trunk/src/pingus_menu.cxx 2005-11-09 22:06:55 UTC (rev 2490)
+++ trunk/src/pingus_menu.cxx 2005-11-10 01:52:16 UTC (rev 2491)
@@ -200,6 +200,7 @@
void PingusMenu::do_edit()
{ // Launch the level editor
+ Sound::PingusSound::stop_music();
ScreenManager::instance()->push_screen (new Editor::EditorScreen());
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Pingus-CVS] r2491 - in trunk/src: . editor,
jave27 <=