[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Pingus-CVS] rev 2301 - trunk/src
From: |
Ingo Ruhnke |
Subject: |
[Pingus-CVS] rev 2301 - trunk/src |
Date: |
Thu, 06 May 2004 15:21:41 +0200 |
Author: grumbel
Date: 2004-05-06 15:21:41 +0200 (Thu, 06 May 2004)
New Revision: 2301
Modified:
trunk/src/action_button.cxx
trunk/src/blitter_impl.hxx
trunk/src/col_map.cxx
trunk/src/credits.cxx
trunk/src/demo_session.cxx
trunk/src/global_event.cxx
trunk/src/pingus_resource.cxx
trunk/src/spot_map.cxx
trunk/src/sprite.cxx
Log:
- some more clanlib related stuff
Modified: trunk/src/action_button.cxx
===================================================================
--- trunk/src/action_button.cxx 2004-05-05 20:50:00 UTC (rev 2300)
+++ trunk/src/action_button.cxx 2004-05-06 13:21:41 UTC (rev 2301)
@@ -140,7 +140,9 @@
sprite.set_direction(Sprite::RIGHT);
gc.draw(sprite, Vector(x_pos + 20, y_pos + 32));
-#ifdef CLANLIB_0_6
+ CL_Font myfont = font;
+ CL_Font myfontb = font_b;
+
// print the action name next to the button, when mouse pointer is on
// the button.
// FIXME: this should use the GUI events, not CL_Mouse
@@ -148,20 +150,23 @@
&& CL_Mouse::get_x() > x_pos && CL_Mouse::get_x() < x_pos + 60
&& CL_Mouse::get_y() < y_pos + 35 && CL_Mouse::get_y() > y_pos)
{
- font_b->print_left(x_pos + 65, y_pos, action_to_screenname(name));
+ myfontb.set_alignment(origin_top_left);
+ myfontb.draw(x_pos + 65, y_pos, action_to_screenname(name));
}
+
if (Cheat::unlimited_actions)
{
// FIXME: insert unlimited surface here
- font->print_center(x_pos + 46, y_pos + 5, "oo");
+ myfont.set_alignment(origin_top_center);
+ myfont.draw(x_pos + 46, y_pos + 5, "oo");
}
else
{
std::string str = to_string(action_holder->get_available(name));
- font->print_center(x_pos + 46, y_pos + 5, str.c_str ());
+ myfont.set_alignment(origin_top_center);
+ myfont.draw(x_pos + 46, y_pos + 5, str.c_str ());
}
-#endif
}
ArmageddonButton::ArmageddonButton (TrueServer* s, int x, int y)
Modified: trunk/src/blitter_impl.hxx
===================================================================
--- trunk/src/blitter_impl.hxx 2004-05-05 20:50:00 UTC (rev 2300)
+++ trunk/src/blitter_impl.hxx 2004-05-06 13:21:41 UTC (rev 2301)
@@ -183,28 +183,29 @@
inline
CL_Surface modify(const CL_Surface& sur, const TransF&)
{
-#ifdef CLANLIB_0_6
- CL_PixelBuffer* prov = sur.get_provider ();
- int pwidth = prov->get_width();
- int pheight = prov->get_height();
+ CL_PixelBuffer prov = sur.get_pixeldata();
- if (prov.get_type() == pixelformat_index)
+ if (prov.get_format().get_type() == pixelformat_index)
{
-#ifdef CLANLIB_0_6
- IndexedCanvas* canvas = new IndexedCanvas(TransF::get_width (pwidth,
pheight),
- TransF::get_height(pwidth,
pheight));
- if (prov->uses_src_colorkey())
- canvas->set_src_colorkey(prov->get_src_colorkey());
+#if CLANLIB_0_6
+ // FIXME: Needs indexed pixelbuffer
+ CL_PixelBuffer canvas(TransF::get_width (pwidth, pheight),
+ TransF::get_height(pwidth, pheight));
- prov->lock ();
- canvas->lock ();
+ if (prov.get_format().has_colorkey())
+ canvas.get_format().set_colorkey(prov.get_format().get_colorkey());
- canvas->set_palette(prov->get_palette());
+ prov.lock ();
+ canvas.lock ();
- unsigned char* source_buf = static_cast<unsigned
char*>(prov->get_data());
- unsigned char* target_buf = static_cast<unsigned
char*>(canvas->get_data());
-#endif
+ canvas.set_palette(prov.get_palette());
+ unsigned char* source_buf = static_cast<unsigned char*>(prov.get_data());
+ unsigned char* target_buf = static_cast<unsigned
char*>(canvas.get_data());
+
+ int pwidth = prov.get_width();
+ int pheight = prov.get_height();
+
for (int y = 0; y < pheight; ++y)
for (int x = 0; x < pwidth; ++x)
{
@@ -226,33 +227,39 @@
target_buf[TransF::get_index(pwidth, pheight, x, y)] =
source_buf[y * pwidth + x];
}
- canvas->unlock ();
- prov->unlock ();
- return CL_Surface(canvas, true);
+ canvas.unlock ();
+ prov.unlock ();
+ return CL_Surface(&canvas, false);
+#endif
+ return CL_Surface();
}
else
{
- CL_PixelBuffer* canvas = Canvas::create(sur.get_height(),
sur.get_width());
+ CL_PixelBuffer canvas(sur.get_height(), sur.get_width(),
sur.get_width()*4, CL_PixelFormat::rgba8888);
- prov->lock ();
- canvas->lock ();
+ prov.lock();
+ canvas.lock();
+#if CLANLIB_0_6
float r, b, g, a;
+ int pwidth = prov.get_width();
+ int pheight = prov.get_height();
+
for (int y = 0; y < sur.get_height (); ++y)
for (int x = 0; x < sur.get_width (); ++x)
{
- prov->get_pixel (x, y, &r, &g, &b, &a);
+
+ prov.get_pixel (x, y, &r, &g, &b, &a);
canvas->draw_pixel (TransF::get_x(pwidth, pheight, x, y),
TransF::get_y(pwidth, pheight, x, y),
r, g, b, a);
}
+#endif
- canvas->unlock ();
- prov->unlock ();
- return CL_Surface(canvas, true);
+ canvas.unlock ();
+ prov.unlock ();
+ return CL_Surface(&canvas, false);
}
-#endif
- return CL_Surface();
}
} // namespace BlitterImpl
Modified: trunk/src/col_map.cxx
===================================================================
--- trunk/src/col_map.cxx 2004-05-05 20:50:00 UTC (rev 2300)
+++ trunk/src/col_map.cxx 2004-05-06 13:21:41 UTC (rev 2301)
@@ -20,6 +20,7 @@
#include <iostream>
#include <assert.h>
#include <ClanLib/Display/pixel_buffer.h>
+#include <ClanLib/Display/pixel_format.h>
#include <ClanLib/Display/surface.h>
#include "gui/graphic_context.hxx"
#include "globals.hxx"
@@ -79,15 +80,12 @@
void
ColMap::remove(CL_PixelBuffer& provider, int x, int y)
{
-#ifdef CLANLIB_0_6
++serial;
- assert(provider);
-
- if (provider.get_depth() == 32)
+ if (provider.get_format().get_depth() == 32)
{
unsigned char* buffer;
- int swidth = provider.get_width();
+ int swidth = provider.get_width();
int sheight = provider.get_height();
int y_offset = -y;
int x_offset = -x;
@@ -108,11 +106,9 @@
}
}
}
-#if COLMAP_WITH_MEMORY_HOLE
provider.unlock();
-#endif
}
- else if (provider.get_depth() == 8)
+ else if (provider.get_format().get_depth() == 8)
{
unsigned char* buffer;
int swidth = provider.get_width();
@@ -136,15 +132,12 @@
}
}
}
-#if COLMAP_WITH_MEMORY_HOLE
provider.unlock();
-#endif
}
else
{
assert(!"ColMap::remove: Color depth not supported");
}
-#endif
}
void
@@ -199,13 +192,13 @@
provider.lock();
-#ifdef CLANLIB_0_6
- if (provider.get_depth() == 32)
+ if (provider.get_format().get_depth() == 32)
{
+#if CLANLIB_0_6
float r, g, b, a;
// Rewritting blitter for 32bit depth (using get_pixel())
- for (unsigned int y=0; y < provider.get_height(); ++y)
- for (unsigned int x=0; x < provider.get_width(); ++x)
+ for (int y=0; y < provider.get_height(); ++y)
+ for (int x=0; x < provider.get_width(); ++x)
{
provider.get_pixel(x, y, &r, &g, &b, &a);
if (a > 0.1) // Alpha threshold
@@ -214,8 +207,9 @@
put(x + sur_x, y + sur_y, pixel);
}
}
+#endif
}
- else if (provider.get_depth() == 8)
+ else if (provider.get_format().get_depth() == 8)
{
unsigned char* buffer;
int swidth = provider.get_width();
@@ -228,9 +222,9 @@
//provider.lock();
buffer = static_cast<unsigned char*>(provider.get_data());
- if (provider.uses_src_colorkey())
+ if (provider.get_format().has_colorkey())
{
- unsigned int colorkey = provider.get_src_colorkey();
+ unsigned int colorkey = provider.get_format().get_colorkey();
for(int line = y_offset; line < sheight && (line + sur_y) < height;
++line)
for (int i = x_offset; i < swidth && (i+sur_x) < width; ++i)
{
@@ -255,7 +249,6 @@
{
std::cout << "ColMap: Unsupported color depth, ignoring" << std::endl;
}
-#endif
// FIXME: Memory hole
// provider.unlock();
Modified: trunk/src/credits.cxx
===================================================================
--- trunk/src/credits.cxx 2004-05-05 20:50:00 UTC (rev 2300)
+++ trunk/src/credits.cxx 2004-05-06 13:21:41 UTC (rev 2301)
@@ -213,7 +213,6 @@
void
Credits::draw_background (GraphicContext& gc)
{
-#ifdef CLANLIB_0_6
int x;
int y;
int yof;
@@ -228,22 +227,25 @@
gc.draw(pingu, (gc.get_width() / 2) - (pingu.get_width() / 2),
(gc.get_height() / 2) - (pingu.get_height() / 2) - 20);
- /*CL_Display::fill_rect(CL_Display::get_width() / 2, 0,
- CL_Display::get_width(), CL_Display::get_height(),
- 0.0, 0.0, 0.0, 1.0);*/
+ CL_Display::push_cliprect(CL_Rect(0, gc.get_height()/2-225, 600,
gc.get_height()/2+200));
+ yof = 0;
- CL_Display::push_clip_rect(CL_Rect(0, gc.get_height()/2-225, 600,
gc.get_height()/2+200));
- yof = 0;
+ CL_Font myfont = font;
+ CL_Font myfont_small = font_small;
+
+ myfont.set_alignment(origin_top_center);
+ myfont_small.set_alignment(origin_top_center);
+
for (std::vector<std::string>::iterator i = credits.begin(); i !=
credits.end(); ++i)
{
switch ((*i)[0])
{
case '-':
- font.print_center(x, y + yof, i->substr(1).c_str());
+ font.draw(x, y + yof, i->substr(1).c_str());
yof += font.get_height() + 5;
break;
case '_':
- font_small.print_center(x, y + yof, i->substr(1).c_str());
+ font_small.draw(x, y + yof, i->substr(1).c_str());
yof += font_small.get_height() + 5;
break;
case 'n':
@@ -254,8 +256,7 @@
break;
}
}
- CL_Display::pop_clip_rect();
-#endif
+ CL_Display::pop_cliprect();
}
void
Modified: trunk/src/demo_session.cxx
===================================================================
--- trunk/src/demo_session.cxx 2004-05-05 20:50:00 UTC (rev 2300)
+++ trunk/src/demo_session.cxx 2004-05-06 13:21:41 UTC (rev 2301)
@@ -55,7 +55,6 @@
void
DemoSession::draw_background(GraphicContext& gc)
{
-#ifdef CLANLIB_0_6
World* world = server->get_world();
if (CL_Keyboard::get_keycode(CL_KEY_LEFT))
@@ -90,7 +89,6 @@
server->get_world()->draw(gc);
CL_System::keep_alive();
}
-#endif
}
/** Pass a delta to the screen */
Modified: trunk/src/global_event.cxx
===================================================================
--- trunk/src/global_event.cxx 2004-05-05 20:50:00 UTC (rev 2300)
+++ trunk/src/global_event.cxx 2004-05-06 13:21:41 UTC (rev 2301)
@@ -44,33 +44,7 @@
{
switch (event.id)
{
-#ifdef CLANLIB_0_6
- // F1 is the general console modifer key...
- case CL_KEY_PAGEUP:
- //if (CL_Keyboard::get_keycode(PINGUS_CL_KEY_HELP))
- //console.increase_lines();
- break;
-
- case CL_KEY_PAGEDOWN:
- //if (CL_Keyboard::get_keycode(PINGUS_CL_KEY_HELP))
- // console.decrease_lines();
- break;
-
- case CL_KEY_UP:
- //if (CL_Keyboard::get_keycode(PINGUS_CL_KEY_HELP))
- // console.scroll_up();
- break;
-
- case CL_KEY_DOWN:
- //if (CL_Keyboard::get_keycode(PINGUS_CL_KEY_HELP))
- // console.scroll_down();
- break;
-
-#ifdef CL_HAS_KEY_GRAVE
- case CL_KEY_GRAVE:
-#else
- case CL_KEY_NONE_OF_THE_ABOVE:
-#endif
+ case CL_KEY_F1:
console.toggle_display();
break;
@@ -96,7 +70,7 @@
break;
case CL_KEY_M:
- if (CL_Keyboard::get_keycode(CL_KEY_LCTRL) ||
CL_Keyboard::get_keycode(CL_KEY_RCTRL) )
+ if (CL_Keyboard::get_keycode(CL_KEY_LCONTROL) ||
CL_Keyboard::get_keycode(CL_KEY_RCONTROL) )
{
std::cout << "Maintainer Mode: " << maintainer_mode << std::endl;
maintainer_mode = !maintainer_mode;
@@ -104,14 +78,12 @@
break;
case CL_KEY_END:
- if (CL_Keyboard::get_keycode(CL_KEY_LCTRL)
- && CL_Keyboard::get_keycode(CL_KEY_ALT))
+ if (CL_Keyboard::get_keycode(CL_KEY_LCONTROL))
{
puts ("---:: Emergency exit ::---");
exit (0);
}
-#endif
default:
// console << "GlobalEvent: Unknown key pressed: " << key.id;
break;
Modified: trunk/src/pingus_resource.cxx
===================================================================
--- trunk/src/pingus_resource.cxx 2004-05-05 20:50:00 UTC (rev 2300)
+++ trunk/src/pingus_resource.cxx 2004-05-06 13:21:41 UTC (rev 2301)
@@ -111,7 +111,13 @@
{
std::cout << "PingusResource::load_sprite: " << res_name << ", " << datafile
<< std::endl;
CL_ResourceManager* res = get(datafile);
- return CL_Sprite(res_name, res);
+ try {
+ CL_Sprite sprite(res_name, res);
+ return sprite;
+ } catch (CL_Error& err) {
+ std::cout << "PingusResource::load_sprite: CL_Error: " << res_name << ", "
<< datafile << std::endl;
+ return CL_Sprite("misc/404sprite", get("core"));
+ }
}
CL_PixelBuffer
Modified: trunk/src/spot_map.cxx
===================================================================
--- trunk/src/spot_map.cxx 2004-05-05 20:50:00 UTC (rev 2300)
+++ trunk/src/spot_map.cxx 2004-05-06 13:21:41 UTC (rev 2301)
@@ -394,11 +394,10 @@
}
else
{
-#ifdef CLANLIB_0_6
-
Blitter::put_surface(static_cast<CL_PixelBuffer*>(tile[ix][iy].surface.get_provider()),
+ CL_PixelBuffer target = tile[ix][iy].surface.get_pixeldata();
+ Blitter::put_surface(target,
sprovider,
x - (ix * tile_size), y - (iy * tile_size));
-#endif
}
/*
CL_Surface s = CL_Surface::create(sprovider);
Modified: trunk/src/sprite.cxx
===================================================================
--- trunk/src/sprite.cxx 2004-05-05 20:50:00 UTC (rev 2300)
+++ trunk/src/sprite.cxx 2004-05-06 13:21:41 UTC (rev 2301)
@@ -50,26 +50,27 @@
void
Sprite::draw (int x, int y)
{
-#ifdef CLANLIB_0_6
// FIXME: HACK
update (0.0f);
switch (direction)
{
case Sprite::NONE:
- sprite.draw(x + x_align, y + y_align, Math::round(frame));
+ sprite.set_frame(Math::round(frame));
+ sprite.draw(x + x_align, y + y_align);
break;
case Sprite::LEFT:
- sprite.draw(x + x_align, y + y_align, Math::round(frame));
+ sprite.set_frame(Math::round(frame));
+ sprite.draw(x + x_align, y + y_align);
break;
case Sprite::RIGHT:
- sprite.draw (x + x_align, y + y_align, Math::round(frame) + max_frames
());
+ sprite.set_frame(Math::round(frame) + max_frames ());
+ sprite.draw (x + x_align, y + y_align);
break;
default:
std::cout << "Direction: " << direction << std::endl;
assert(0);
}
-#endif
}
void
@@ -81,11 +82,10 @@
void
Sprite::draw(GraphicContext& gc, const Vector& pos)
{
-#ifdef CLANLIB_0_6
if (!sprite)
return;
- // FIXME: HACK
+ // FIXME: HACK <- hack for what?
update (0.0f);
int x = int(pos.x);
@@ -95,18 +95,17 @@
{
case Sprite::NONE:
case Sprite::LEFT:
- gc.draw(sprite, x + x_align, y + y_align, Math::round(frame));
+ gc.draw(sprite, Vector(x + x_align, y + y_align), Math::round(frame));
break;
case Sprite::RIGHT:
- gc.draw(sprite, x + x_align, y + y_align, Math::round(frame) +
max_frames ());
+ gc.draw(sprite, Vector(x + x_align, y + y_align), Math::round(frame) +
max_frames ());
break;
default:
std::cout << "Direction: " << direction << std::endl;
assert(0);
}
-#endif
}
void
@@ -119,42 +118,34 @@
void
Sprite::set_align_center ()
{
-#ifdef CLANLIB_0_6
x_align = -int(sprite.get_width ())/2;
y_align = -int(sprite.get_height ())/2;
-#endif
}
void
Sprite::set_align_center_bottom ()
{
-#ifdef CLANLIB_0_6
x_align = -int(sprite.get_width ())/2;
y_align = -int(sprite.get_height ());
-#endif
}
void
Sprite::next_frame ()
{
-#ifdef CLANLIB_0_6
++frame;
if (Math::round(frame) >= int(sprite.get_frame_count()))
frame = 0;
-#endif
}
void
Sprite::previous_frame ()
{
-#ifdef CLANLIB_0_6
--frame;
if (Math::round(frame) < 0)
frame = sprite.get_frame_count() - 1;
-#endif
}
@@ -173,7 +164,6 @@
int
Sprite::max_frames ()
{
-#ifdef CLANLIB_0_6
switch (direction)
{
case NONE:
@@ -185,9 +175,6 @@
assert (0);
return 0;
}
-#else
- return 0;
-#endif
}
void
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Pingus-CVS] rev 2301 - trunk/src,
Ingo Ruhnke <=