Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'src/dedicated')
-rw-r--r--src/dedicated/console.cc34
-rw-r--r--src/dedicated/console.h5
2 files changed, 20 insertions, 19 deletions
diff --git a/src/dedicated/console.cc b/src/dedicated/console.cc
index 90acb7a..31b35ff 100644
--- a/src/dedicated/console.cc
+++ b/src/dedicated/console.cc
@@ -17,7 +17,7 @@
#include "sys/consoleinterface.h"
#ifdef HAVE_CURSES
-#include <ncurses.h>
+#include <curses.h>
#endif
namespace dedicated {
@@ -192,10 +192,10 @@ void Console::draw_background()
color_set(2, NULL);
std::string versionstr("The Osirion Project ");
versionstr.append(core::version());
- int y = stdwin->_maxx - 1 - versionstr.size();
+ int y = console_width - versionstr.size();
if (y < 0)
y = 0;
- mvaddnstr(0, y, versionstr.c_str(), stdwin->_maxx - 1);
+ mvaddnstr(0, y, versionstr.c_str(), console_width);
}
void Console::draw_status()
@@ -212,22 +212,17 @@ void Console::draw_status()
}
void Console::draw_text()
{
- int w = stdwin->_maxx;
- int h = stdwin->_maxy;
-
- if ((w < 3) || (h < 3))
+ if ((console_width < 4) || (console_height < 3))
return;
Queue lines;
- int height = stdwin->_maxy - 1;
- int width = stdwin->_maxx - 1;
int bottom = (int) log().size() - console_scroll;
int current_line = 0;
// parse console text, wrap long lines
for (Queue::iterator it = log().begin(); it != log().end() && current_line < bottom; it++) {
- if (current_line >= bottom - height) {
+ if (current_line >= bottom - console_height - 1) {
std::string linedata(*it);
linedata += '\n';
@@ -254,7 +249,7 @@ void Console::draw_text()
// new word, wrap if necessary
else if ((*c == '\n' ) || ( *c == ' ')) {
- if (line_length + word_length > width) {
+ if (line_length + word_length > console_width) {
if (line.size()) {
lines.push_back(line);
line.clear();
@@ -288,7 +283,7 @@ void Console::draw_text()
word += *c;
word_length++;
- if (word_length == width) {
+ if (word_length == console_width) {
if (line.size()) {
lines.push_back(line);
line.clear();
@@ -313,7 +308,7 @@ void Console::draw_text()
current_line++;
}
- int y = stdwin->_maxy - 1;
+ int y = console_height - 1;
color_set(0, NULL);
attroff(A_BOLD);
@@ -341,10 +336,10 @@ void Console::draw_input()
color_set(0, NULL);
attron(A_BOLD);
// draw input text
- mvaddstr(stdwin->_maxy, 0, ">");
- mvaddstr(stdwin->_maxy, 1, (*history_pos).c_str());
+ mvaddstr(console_height, 0, ">");
+ mvaddstr(console_height, 1, (*history_pos).c_str());
// fill the remainder with spaces
- for (int i=1 + (*history_pos).size(); i < stdwin->_maxx; i++)
+ for (int i=1 + (*history_pos).size(); i < console_width; i++)
addch(' ');
}
@@ -353,11 +348,14 @@ void Console::draw()
if (!console_initialized)
return;
+ console_width = stdwin->_maxx -1;
+ console_height = stdwin->_maxy -1;
+
draw_background();
draw_status();
draw_text();
draw_input();
- move(stdwin->_maxy, 1 + input_pos);
+ move(console_height, 1 + input_pos);
wrefresh(stdwin);
console_updated = false;
@@ -477,7 +475,7 @@ void Console::frame()
}
if (input_updated) {
// move the cursor to input position
- move(stdwin->_maxy, 1 + input_pos);
+ move(console_height, 1 + input_pos);
wrefresh(stdwin);
}
}
diff --git a/src/dedicated/console.h b/src/dedicated/console.h
index 6ab26ba..19ea906 100644
--- a/src/dedicated/console.h
+++ b/src/dedicated/console.h
@@ -54,7 +54,10 @@ private:
History::reverse_iterator history_pos;
size_t input_pos;
- size_t console_scroll;
+ size_t console_scroll;
+
+ int console_width;
+ int console_height;
#endif
};