|
From: <ufo...@li...> - 2010-06-20 22:35:45
|
Revision: 1151
http://ufo2000.svn.sourceforge.net/ufo2000/?rev=1151&view=rev
Author: ssvb
Date: 2010-06-20 22:35:38 +0000 (Sun, 20 Jun 2010)
Log Message:
-----------
Added support for setting background picture for ConsoleWindow class
From: Siarhei Siamashka <sia...@gm...>
Modified Paths:
--------------
trunk/src/wind.cpp
trunk/src/wind.h
Modified: trunk/src/wind.cpp
===================================================================
--- trunk/src/wind.cpp 2010-06-19 23:32:17 UTC (rev 1150)
+++ trunk/src/wind.cpp 2010-06-20 22:35:38 UTC (rev 1151)
@@ -105,17 +105,23 @@
return false;
}
-ConsoleWindow::ConsoleWindow(int width, int height, FONT *font)
+ConsoleWindow::ConsoleWindow(int width, int height, BITMAP *bg, FONT *font)
{
m_width = width;
m_height = height;
m_font = font;
+ m_background_bmp = NULL;
+ if (bg) {
+ m_background_bmp = create_bitmap(bg->w, bg->h);
+ blit(bg, m_background_bmp, 0, 0, 0, 0, bg->w, bg->h);
+ }
m_status_line = new ConsoleStatusLine(width, font, COLOR_WHITE);
m_need_redraw = true;
}
ConsoleWindow::~ConsoleWindow()
{
+ destroy_bitmap(m_background_bmp);
delete m_status_line;
}
@@ -125,7 +131,15 @@
acquire_bitmap(bmp);
BITMAP *temp_bmp = create_bitmap(m_width, m_height);
- clear_to_color(temp_bmp, COLOR_BLACK1);
+ if (m_background_bmp) {
+ int x, y;
+ for (y = 0; y < m_height; y += m_background_bmp->h)
+ for (x = 0; x < m_width; x += m_background_bmp->w)
+ blit(m_background_bmp, temp_bmp, 0, 0, x, y,
+ m_background_bmp->w, m_background_bmp->h);
+ } else {
+ clear_to_color(temp_bmp, COLOR_BLACK1);
+ }
int lines_to_show = (m_height - m_status_line->get_height()) / text_height(m_font);
for (int i = m_lines_text.size() - 1, j = 1; i >= 0 && j <= lines_to_show; i--, j++) {
text_mode(-1);
Modified: trunk/src/wind.h
===================================================================
--- trunk/src/wind.h 2010-06-19 23:32:17 UTC (rev 1150)
+++ trunk/src/wind.h 2010-06-20 22:35:38 UTC (rev 1151)
@@ -105,9 +105,11 @@
std::vector<int> m_lines_color;
ConsoleStatusLine *m_status_line;
FONT *m_font;
+ BITMAP *m_background_bmp;
bool m_need_redraw;
public:
- ConsoleWindow(int width, int height, FONT *font = g_console_font);
+ ConsoleWindow(int width, int height, BITMAP *bg = NULL,
+ FONT *font = g_console_font);
virtual ~ConsoleWindow();
virtual void redraw_full(BITMAP *bmp, int x, int y);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|