pingus-cvs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Pingus-CVS] r2545 - trunk/src/editor


From: jave27
Subject: [Pingus-CVS] r2545 - trunk/src/editor
Date: Wed, 7 Dec 2005 04:52:16 +0100

Author: jave27
Date: 2005-12-07 04:52:07 +0100 (Wed, 07 Dec 2005)
New Revision: 2545

Modified:
   trunk/src/editor/editor_viewport.cxx
   trunk/src/editor/editor_viewport.hxx
   trunk/src/editor/level_objs.cxx
   trunk/src/editor/level_objs.hxx
   trunk/src/editor/xml_level.cxx
Log:
Some more basic editor cleanup, testing


Modified: trunk/src/editor/editor_viewport.cxx
===================================================================
--- trunk/src/editor/editor_viewport.cxx        2005-12-07 01:23:08 UTC (rev 
2544)
+++ trunk/src/editor/editor_viewport.cxx        2005-12-07 03:52:07 UTC (rev 
2545)
@@ -34,19 +34,15 @@
 
 // Constructor
 EditorViewport::EditorViewport(EditorScreen* e) :
-       state((int)(end_pos.x - start_pos.x), (int)(end_pos.y - start_pos.y)),
        scene_context(new SceneContext()),
        editor(e),
        bg_surface(0),
-       start_pos(Vector(10.0f, 60.0f)),
-       end_pos(Vector((float)(CL_Display::get_width() - 10), 
-                                               
(float)(CL_Display::get_height() - 10))),
+       state(CL_Display::get_width(), CL_Display::get_height()),
        autoscroll(true)
 {
-       state.set_limit(CL_Rect((int)start_pos.x, (int)start_pos.y, 
-               (int)end_pos.x, (int)end_pos.y));
-       state.set_pos(CL_Pointf((float)(state.get_width() / 2), 
-               (float)(state.get_height() / 2)));
+       // FIXME: Hardcoded values should be determined by level size
+       state.set_limit(CL_Rect(-30, -50, 1600, 1300));
+       state.set_pos(CL_Pointf(0, 0));
 }
 
 // Destructor
@@ -59,8 +55,9 @@
 void
 EditorViewport::on_secondary_button_click(int x, int y)
 {
-       std::cout << "Right-click at " << x - start_pos.x << ", " 
-               << y - start_pos.y << std::endl;
+       // FIXME: Hardcoded 15 & 25 should probably be dynamic
+       std::cout << "Right-click at " << x - 15 - (state.get_width()/2 - 
state.get_pos().x) << ", " 
+               << y - 25 - (state.get_height()/2 - state.get_pos().y) << 
std::endl;
 }
 
 // Draws all of the objects in the viewport and the background (if any)
@@ -72,14 +69,10 @@
        
        // Now, draw all of the objects
 
-       // FIXME: Should draw the background over the whole viewport (stretched 
or tiled)
+       // FIXME: Should draw the background(s) over the whole viewport 
(stretched or tiled)
        if (bg_surface)
-               scene_context->color().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, -5000);
+               scene_context->color().draw(*bg_surface, Vector());
 
-
        // FIXME: This is obviously not correct, but it's just a proof of 
concept now.
        // Draw the level objects
        std::vector<LevelObj*> objs = editor->get_level()->get_objects();
@@ -87,16 +80,15 @@
                objs[i]->draw(scene_context->color());
 
        state.pop(*scene_context);
-       gc.draw(new SceneContextDrawingRequest(scene_context, 
CL_Vector(state.get_pos().x,
-               state.get_pos().y)));
+       gc.draw(new SceneContextDrawingRequest(scene_context, CL_Vector(0, 0, 
-5000)));
 }
 
 // Returns true if the viewport is at the x,y coordinate
 bool
 EditorViewport::is_at(int x, int y)
 {
-  return (x > start_pos.x && x < end_pos.x
-         && y > start_pos.y && y < end_pos.y);
+       // FIXME: Should return true everywhere except for on the panel
+       return true;
 }
 
 // 
@@ -115,13 +107,13 @@
                const int autoscroll_border = 10;
                if (autoscroll)
                {
-                       if (mouse_at.x - start_pos.x < autoscroll_border)
+                       if (mouse_at.x < autoscroll_border)
                                state.set_pos(state.get_pos() - CL_Pointf(5, 
0));
-                       else if (end_pos.x - mouse_at.x < autoscroll_border)
+                       else if ((float)CL_Display::get_width() - mouse_at.x < 
autoscroll_border)
                                state.set_pos(state.get_pos() + CL_Pointf(5, 
0));
-                       else if (mouse_at.y - start_pos.y < autoscroll_border)
+                       else if (mouse_at.y < autoscroll_border)
                                state.set_pos(state.get_pos() - CL_Pointf(0, 
5));
-                       else if (end_pos.y - mouse_at.y < autoscroll_border)
+                       else if ((float)CL_Display::get_height() - mouse_at.y < 
autoscroll_border)
                                state.set_pos(state.get_pos() + CL_Pointf(0, 
5));
                }
        }

Modified: trunk/src/editor/editor_viewport.hxx
===================================================================
--- trunk/src/editor/editor_viewport.hxx        2005-12-07 01:23:08 UTC (rev 
2544)
+++ trunk/src/editor/editor_viewport.hxx        2005-12-07 03:52:07 UTC (rev 
2545)
@@ -85,12 +85,14 @@
        /** Background image - if null, will display dark gray background */
        CL_Surface* bg_surface;
 
-       /** Vector where this Viewport starts */
+       /** Vector where this Viewport starts 
        Vector start_pos;
 
-       /** Vector where this Viewport ends */
+       /** Vector where this Viewport ends 
        Vector end_pos;
 
+       */
+
        /** Whether or not Autoscrolling is turned on */
        bool autoscroll;
 

Modified: trunk/src/editor/level_objs.cxx
===================================================================
--- trunk/src/editor/level_objs.cxx     2005-12-07 01:23:08 UTC (rev 2544)
+++ trunk/src/editor/level_objs.cxx     2005-12-07 03:52:07 UTC (rev 2545)
@@ -20,6 +20,7 @@
 #include <string>
 #include <iostream>
 #include "level_objs.hxx"
+#include "../blitter.hxx"
 #include "../resource.hxx"
 #include "../res_descriptor.hxx"
 #include "../display/drawing_context.hxx"
@@ -67,23 +68,70 @@
                        for(int x = static_cast<int>(pos.x); x < pos.x + width; 
x += sprite.get_width())
                                gc.draw(sprite, Vector(static_cast<float>(x), 
pos.y));
                }
+               else if(attribs & HAS_STRETCH)
+               {
+                       // Surface Background - tile it
+                       gc.draw(sprite, pos);
+               }
                else
                        gc.draw(sprite, pos);
        }
 }
 
+void
+LevelObj::set_stretch_x(const bool s)
+{ 
+       stretch_x = s;
+       refresh_sprite();
+}
+
+void
+LevelObj::set_stretch_y(const bool s)
+{ 
+       stretch_y = s;
+       refresh_sprite();
+}
+
+void
+LevelObj::set_aspect(const bool a)
+{ 
+       keep_aspect = a;
+       refresh_sprite();
+}
+
+void
+LevelObj::refresh_sprite()
+{
+       // Apply modifier, then change the sprite loaded for this object in 
memory.
+       CL_SpriteDescription sprite_desc;
+       sprite_desc = Resource::load_sprite_desc(desc.res_name);
+       CL_Sprite spr = CL_Sprite(sprite_desc);
+       sprite_desc = CL_SpriteDescription();
+       CL_Surface sur = Resource::apply_modifier(spr.get_frame_surface(0), 
desc);
+       sprite_desc.add_frame(sur.get_pixeldata());
+       sprite = CL_Sprite(sprite_desc);
+
+       if (stretch_x || stretch_y)
+       {
+               float w, h;
+               // FIXME: Temporary hack
+               w = 800;
+               h = 600;
+
+               sur = 
Blitter::scale_surface_to_canvas(sprite.get_frame_surface(0), w, h);
+               sprite_desc = CL_SpriteDescription();
+               sprite_desc.add_frame(sur.get_pixeldata());
+               sprite = CL_Sprite(sprite_desc);
+       }
+}
+
 // Set the modifier and actually modify the sprite loaded in memory
 void
 LevelObj::set_modifier(const std::string m)
 {
        // Set modifier
        desc.modifier = ResourceModifierNS::rs_from_string(m);
-
-       // Apply modifier, then change the sprite loaded for this object in 
memory.
-       CL_Surface sur = Resource::apply_modifier(sprite.get_frame_surface(0), 
desc);
-       CL_SpriteDescription desc;
-       desc.add_frame(sur.get_pixeldata());
-       sprite = CL_Sprite(desc);
+       refresh_sprite();
 }
 
 // Writes the XML attributes for the file

Modified: trunk/src/editor/level_objs.hxx
===================================================================
--- trunk/src/editor/level_objs.hxx     2005-12-07 01:23:08 UTC (rev 2544)
+++ trunk/src/editor/level_objs.hxx     2005-12-07 03:52:07 UTC (rev 2545)
@@ -135,8 +135,11 @@
        /** Write any additional properties to the XML file for this type */
        virtual void write_extra_properties(XMLFileWriter& xml) { }
 
+       /** Call when the sprite needs to be reloaded */
+       void refresh_sprite();
 
 
+
 /////////////////////////////////////////////////////////
 /// Retrieve info
 public:
@@ -232,13 +235,13 @@
        void set_scroll_y(const float s) { scroll_y = s; }
 
        /** Set the objects stretch in the x direction value */
-       void set_stretch_x(const bool s) { stretch_x = s; }
+       void set_stretch_x(const bool s);
 
        /** Set the objects stretch in the y direction value */
-       void set_stretch_y(bool s) { stretch_y = s; }
+       void set_stretch_y(bool s);
 
        /** Set whether or not the object should maintain it's aspect ratio 
when stretched */
-       void set_aspect(const bool a) { keep_aspect = a; }
+       void set_aspect(const bool a);
 
        /** Set the objects color if applicable */
        void set_color(const CL_Colorf c) 

Modified: trunk/src/editor/xml_level.cxx
===================================================================
--- trunk/src/editor/xml_level.cxx      2005-12-07 01:23:08 UTC (rev 2544)
+++ trunk/src/editor/xml_level.cxx      2005-12-07 03:52:07 UTC (rev 2545)
@@ -52,7 +52,7 @@
  LevelObj's:
  - At least 1 entrance
  - At least 1 exit
- - Exactly 1 surface-background
+ - At least 1 surface-background
  - Each object should be within valid ranges (pos Vector should be inside the 
world)
  -----------
  Head section:





reply via email to

[Prev in Thread] Current Thread [Next in Thread]