/* leveleditor internals */
static string_list_type level_subsets;
static bool le_level_changed; /* if changes, ask for saving, when quiting*/
+static bool show_minimap;
static int pos_x, cursor_x, cursor_y, fire;
static int le_level;
static LevelEditorWorld le_world;
}
}
+void le_drawminimap()
+{
+if(le_current_level == NULL)
+return;
+
+int mini_tile_width;
+if(screen->w - 64 > le_current_level->width * 4)
+mini_tile_width = 4;
+else if(screen->w - 64 > le_current_level->width * 2)
+mini_tile_width = 2;
+else
+mini_tile_width = 1;
+int left_offset = (screen->w - 64 - le_current_level->width*mini_tile_width) / 2;
+
+ for (int y = 0; y < 15; ++y)
+ for (int x = 0; x < le_current_level->width; ++x)
+ {
+
+ Tile::draw_stretched(left_offset + mini_tile_width*x, y * 4, mini_tile_width , 4, le_current_level->bg_tiles[y][x]);
+
+ Tile::draw_stretched(left_offset + mini_tile_width*x, y * 4, mini_tile_width , 4, le_current_level->ia_tiles[y][x]);
+
+ Tile::draw_stretched(left_offset + mini_tile_width*x, y * 4, mini_tile_width , 4, le_current_level->fg_tiles[y][x]);
+
+ }
+
+fillrect(left_offset, 0, le_current_level->width*mini_tile_width, 15*4, 200, 200, 200, 128);
+
+fillrect(left_offset + (pos_x/32)*mini_tile_width, 0, 19*mini_tile_width, 2, 200, 200, 200, 200);
+fillrect(left_offset + (pos_x/32)*mini_tile_width, 0, 2, 15*4, 200, 200, 200, 200);
+fillrect(left_offset + (pos_x/32)*mini_tile_width + 19*mini_tile_width - 2, 0, 2, 15*4, 200, 200, 200, 200);
+fillrect(left_offset + (pos_x/32)*mini_tile_width, 15*4-2, 19*mini_tile_width, 2, 200, 200, 200, 200);
+
+}
+
void le_drawinterface()
{
int x,y;
fillrect(0, y*32, screen->w - 32, 1, 225, 225, 225,255);
}
}
+
+ if(show_minimap && use_gl) // use_gl because the minimap isn't shown correctly in software mode. Any idea? FIXME Possible reasons: SDL_SoftStretch is a hack itsself || an alpha blitting issue SDL can't handle in software mode
+ le_drawminimap();
if(le_selection_mode == CURSOR)
if(le_current.IsTile())
}
if(!Menu::current())
{
+ show_minimap = false;
+
if(le_move_left_bt->get_state() == BUTTON_PRESSED)
{
pos_x -= 192;
+ show_minimap = true;
}
else if(le_move_left_bt->get_state() == BUTTON_HOVER)
{
pos_x -= 32;
+ show_minimap = true;
}
if(le_move_right_bt->get_state() == BUTTON_PRESSED)
{
pos_x += 192;
+ show_minimap = true;
}
else if(le_move_right_bt->get_state() == BUTTON_HOVER)
{
pos_x += 32;
+ show_minimap = true;
}
}
}
void
+Surface::draw_stretched(float x, float y, int w, int h, Uint8 alpha, bool update)
+{
+ if (impl)
+ {
+ if (impl->draw_stretched(x, y, w, h, alpha, update) == -2)
+ reload();
+ }
+}
+
+void
Surface::resize(int w_, int h_)
{
if (impl)
(void) update; // avoid warnings
return 0;
}
+
+int
+SurfaceOpenGL::draw_stretched(float x, float y, int sw, int sh, Uint8 alpha, bool update)
+{
+ float pw = power_of_two(int(this->w));
+ float ph = power_of_two(int(this->h));
+
+ glBindTexture(GL_TEXTURE_2D, gl_texture);
+
+ glEnable(GL_BLEND);
+ glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
+
+ glColor4ub(alpha, alpha, alpha, alpha);
+
+ glEnable(GL_TEXTURE_2D);
+
+
+ glBegin(GL_QUADS);
+ glTexCoord2f(0, 0);
+ glVertex2f(x, y);
+ glTexCoord2f((float)w / pw, 0);
+ glVertex2f(sw+x, y);
+ glTexCoord2f((float)w / pw, (float)h / ph); glVertex2f((float)sw+x, (float)sh+y);
+ glVertex2f(sw +x, sh+y);
+ glTexCoord2f(0, (float)h / ph);
+ glVertex2f(x, sh+y);
+ glEnd();
+
+ glDisable(GL_TEXTURE_2D);
+ glDisable(GL_BLEND);
+
+ (void) update; // avoid warnings
+ return 0;
+}
+
#endif
SurfaceSDL::SurfaceSDL(SDL_Surface* surf, int use_alpha)
return ret;
}
+int
+SurfaceSDL::draw_stretched(float x, float y, int sw, int sh, Uint8 alpha, bool update)
+{
+ SDL_Rect dest;
+
+ dest.x = (int)x;
+ dest.y = (int)y;
+ dest.w = (int)sw;
+ dest.h = (int)sh;
+
+ if(alpha != 255)
+ SDL_SetAlpha(sdl_surface ,SDL_SRCALPHA,alpha);
+
+ int ret = SDL_SoftStretch(sdl_surface, NULL, screen, &dest);
+
+ if (update == UPDATE)
+ update_rect(screen, dest.x, dest.y, dest.w, dest.h);
+
+ return ret;
+}
+
SurfaceSDL::~SurfaceSDL()
{}
void draw(float x, float y, Uint8 alpha = 255, bool update = false);
void draw_bg(Uint8 alpha = 255, bool update = false);
void draw_part(float sx, float sy, float x, float y, float w, float h, Uint8 alpha = 255, bool update = false);
- void Surface::resize(int w_, int h_);
+ void draw_stretched(float x, float y, int w, int h, Uint8 alpha, bool update = false);
+ void resize(int w_, int h_);
};
/** Surface implementation, all implementation have to inherit from
virtual int draw(float x, float y, Uint8 alpha, bool update) = 0;
virtual int draw_bg(Uint8 alpha, bool update) = 0;
virtual int draw_part(float sx, float sy, float x, float y, float w, float h, Uint8 alpha, bool update) = 0;
+ virtual int draw_stretched(float x, float y, int w, int h, Uint8 alpha, bool update) = 0;
int resize(int w_, int h_);
SDL_Surface* get_sdl_surface() const; // @evil@ try to avoid this function
int draw(float x, float y, Uint8 alpha, bool update);
int draw_bg(Uint8 alpha, bool update);
int draw_part(float sx, float sy, float x, float y, float w, float h, Uint8 alpha, bool update);
+ int draw_stretched(float x, float y, int w, int h, Uint8 alpha, bool update);
};
#ifndef NOOPENGL
int draw(float x, float y, Uint8 alpha, bool update);
int draw_bg(Uint8 alpha, bool update);
int draw_part(float sx, float sy, float x, float y, float w, float h, Uint8 alpha, bool update);
+ int draw_stretched(float x, float y, int w, int h, Uint8 alpha, bool update);
private:
void create_gl(SDL_Surface * surf, GLuint * tex);
}
}
+void
+Tile::draw_stretched(float x, float y, int w, int h, unsigned int c, Uint8 alpha)
+{
+ if (c != 0)
+ {
+ Tile* ptile = TileManager::instance()->get(c);
+ if(ptile)
+ {
+ if(ptile->images.size() > 1)
+ {
+ ptile->images[( ((global_frame_counter*25) / ptile->anim_speed) % (ptile->images.size()))]->draw_stretched(x,y,w,h, alpha);
+ }
+ else if (ptile->images.size() == 1)
+ {
+ ptile->images[0]->draw_stretched(x,y, w, h, alpha);
+ }
+ else
+ {
+ //printf("Tile not dravable %u\n", c);
+ }
+ }
+ }
+}
+
// EOF //
/** Draw a tile on the screen: */
static void draw(float x, float y, unsigned int c, Uint8 alpha = 255);
+ static void draw_stretched(float x, float y, int w, int h, unsigned int c, Uint8 alpha = 255);
};
struct TileGroup