Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStijn Buys <ingar@osirion.org>2008-02-06 00:56:15 +0000
committerStijn Buys <ingar@osirion.org>2008-02-06 00:56:15 +0000
commit15ca94f41b77cdf439774fe1e6502979be9d3f8e (patch)
tree8793f4394e76c685640d34b6de30911ebc416a6c
parent00a039fffea099eb53d2bbe77d3300b3d7ea768f (diff)
console scroll
-rw-r--r--osirion.kdevelop2
-rw-r--r--osirion.kdevelop.pcsbin287842 -> 298526 bytes
-rw-r--r--osirion.kdevses16
-rw-r--r--src/client/console.cc46
-rw-r--r--src/client/console.h2
-rw-r--r--src/client/video.cc10
-rw-r--r--src/core/cvar.cc14
-rw-r--r--src/core/func.cc2
8 files changed, 54 insertions, 38 deletions
diff --git a/osirion.kdevelop b/osirion.kdevelop
index d40c050..58a8bfc 100644
--- a/osirion.kdevelop
+++ b/osirion.kdevelop
@@ -21,7 +21,7 @@
</general>
<kdevautoproject>
<general>
- <activetarget>src/core/libcore.la</activetarget>
+ <activetarget>src/client/libclient.la</activetarget>
<useconfiguration>debug</useconfiguration>
</general>
<run>
diff --git a/osirion.kdevelop.pcs b/osirion.kdevelop.pcs
index 403fa43..e70b121 100644
--- a/osirion.kdevelop.pcs
+++ b/osirion.kdevelop.pcs
Binary files differ
diff --git a/osirion.kdevses b/osirion.kdevses
index a179a02..cc06cff 100644
--- a/osirion.kdevses
+++ b/osirion.kdevses
@@ -1,19 +1,13 @@
<?xml version = '1.0' encoding = 'UTF-8'?>
<!DOCTYPE KDevPrjSession>
<KDevPrjSession>
- <DocsAndViews NumberOfDocuments="4" >
- <Doc0 NumberOfViews="1" URL="file:///home/ingar/projects/osirion/osirion-work/src/core/application.cc" >
- <View0 Encoding="" line="78" Type="Source" />
+ <DocsAndViews NumberOfDocuments="2" >
+ <Doc0 NumberOfViews="1" URL="file:///home/ingar/projects/osirion/osirion-work/src/client/video.cc" >
+ <View0 Encoding="" line="105" Type="Source" />
</Doc0>
- <Doc1 NumberOfViews="1" URL="file:///home/ingar/projects/osirion/osirion-work/src/client/client.cc" >
- <View0 Encoding="" line="137" Type="Source" />
+ <Doc1 NumberOfViews="1" URL="file:///home/ingar/projects/osirion/osirion-work/src/core/cvar.cc" >
+ <View0 Encoding="" line="81" Type="Source" />
</Doc1>
- <Doc2 NumberOfViews="1" URL="file:///home/ingar/projects/osirion/osirion-work/src/server/server.cc" >
- <View0 Encoding="" line="60" Type="Source" />
- </Doc2>
- <Doc3 NumberOfViews="1" URL="file:///home/ingar/projects/osirion/osirion-work/src/core/core.h" >
- <View0 Encoding="" line="25" Type="Source" />
- </Doc3>
</DocsAndViews>
<pluginList>
<kdevdebugger>
diff --git a/src/client/console.cc b/src/client/console.cc
index 42ef78a..83d69de 100644
--- a/src/client/console.cc
+++ b/src/client/console.cc
@@ -50,6 +50,9 @@ std::deque<std::string> text;
// console visibility
bool console_visible;
+size_t console_scroll = 0;
+size_t input_pos = 0;
+
//--- engine functions --------------------------------------------
extern "C" void func_con_toggle(std::stringstream &args)
@@ -108,23 +111,29 @@ void draw()
gl::end();
// draw the console text
+ if (console_scroll > text.size())
+ console_scroll = text.size();
+
gl::enable(GL_TEXTURE_2D);
std::deque<std::string>::reverse_iterator rit = text.rbegin();
- float y = video::height*con_height-2*CHARHEIGHT-8;
+ float bottom = video::height*con_height-2*CHARHEIGHT-8;
+ float y = bottom+console_scroll*CHARHEIGHT;
while (y > 0 && rit < text.rend()) {
- std::string line(*rit);
+ if (y <= bottom) {
+ std::string line(*rit);
- if (line[0] == '?')
- gl::color(0.7f,0.7f,0.7f, 1.0f);
- else if (line[0] == '*')
- gl::color(1.0f,1.0f,0.0f, 1.0f);
- else if (line[0] == '!')
- gl::color(1.0f,0.0f,0.0f, 1.0f);
- else
- gl::color(1.0f,1.0f,1.0f, 1.0f);
- line.erase(0,2);
-
- draw_text(CHARWIDTH, y, line);
+ if (line[0] == '?')
+ gl::color(0.7f,0.7f,0.7f, 1.0f);
+ else if (line[0] == '*')
+ gl::color(1.0f,1.0f,0.0f, 1.0f);
+ else if (line[0] == '!')
+ gl::color(1.0f,0.0f,0.0f, 1.0f);
+ else
+ gl::color(1.0f,1.0f,1.0f, 1.0f);
+ line.erase(0,2);
+
+ draw_text(CHARWIDTH, y, line);
+ }
y -= CHARHEIGHT;
++rit;
}
@@ -159,6 +168,9 @@ void toggle()
{
console_visible = !console_visible;
setkeyboardmode(console_visible);
+ console_scroll = 0;
+ input.clear();
+ input_pos = 0;
}
void keypressed(const SDL_keysym &keysym)
@@ -175,6 +187,14 @@ void keypressed(const SDL_keysym &keysym)
input.erase(input.size()-1, 1);
}
break;
+ case SDLK_PAGEUP:
+ console_scroll +=5;
+ if (console_scroll > text.size()) console_scroll = text.size();
+ break;
+ case SDLK_PAGEDOWN:
+ if (console_scroll > 5) console_scroll -=5;
+ else console_scroll = 0;
+ break;
default:
break;
}
diff --git a/src/client/console.h b/src/client/console.h
index 3ea064e..e558438 100644
--- a/src/client/console.h
+++ b/src/client/console.h
@@ -14,7 +14,7 @@
#include <sstream>
#include <deque>
-#define MAXCONLINES 2048
+const size_t MAXCONLINES=2048;
namespace client {
diff --git a/src/client/video.cc b/src/client/video.cc
index f7ae792..19555ec 100644
--- a/src/client/video.cc
+++ b/src/client/video.cc
@@ -84,7 +84,8 @@ bool init()
SDL_GL_SetAttribute( SDL_GL_ALPHA_SIZE, 2);
SDL_GL_SetAttribute( SDL_GL_DOUBLEBUFFER, 1 );
- flags = SDL_OPENGL | SDL_FULLSCREEN;
+ if (r_fullscreen->value()) flags = SDL_OPENGL | SDL_FULLSCREEN;
+ else flags = SDL_OPENGL;
if(!SDL_SetVideoMode(width, height, bpp, flags )) {
con_warn << "Failed to set video mode " << width << "x" << height << "x" << bpp << "bpp" << std::endl;
@@ -101,14 +102,15 @@ bool init()
con_print << " video mode " << width << "x" << height << "x" << bpp << "bpp" << std::endl;
aspect = (float) width / (float) height;
-
+ (*r_width) = width;
+ (*r_height) = height;
render::init();
+ video::reset();
+
view::init();
- video::reset();
-
return true;
}
diff --git a/src/core/cvar.cc b/src/core/cvar.cc
index a1444ae..f7402ab 100644
--- a/src/core/cvar.cc
+++ b/src/core/cvar.cc
@@ -77,9 +77,9 @@ Cvar get(const char *name, const char *value, int flags)
{
Cvar c = find(name);
if (c) {
- con_debug << "cvar::get " << name << " already exist with value " << value << std::endl;
+ //con_debug << "cvar::get " << name << " already exist with value " << cvar->text() << std::endl;
} else {
- con_debug << "cvar::get " << name << " " << value << std::endl;
+ //con_debug << "cvar::get " << name << " " << value << std::endl;
c = new Cvar_t(flags);
registry[std::string(name)] = c;
(*c) = value;
@@ -91,9 +91,9 @@ Cvar get(const char *name, float value, int flags)
{
Cvar c = find(name);
if (c) {
- con_debug << "cvar::get " << name << " already exist with value " << value << std::endl;
+ //con_debug << "cvar::get " << name << " already exist with value " << cvar->text() << std::endl;
} else {
- con_debug << "cvar::get " << name << " " << value << std::endl;
+ //con_debug << "cvar::get " << name << " " << value << std::endl;
c = new Cvar_t(flags);
registry[std::string(name)] = c;
(*c) = value;
@@ -108,8 +108,8 @@ Cvar set(const char *name, const char *value, int flags)
c = new Cvar_t(flags);
registry[std::string(name)] = c;
}
- con_debug << "cvar::set " << name << " " << value << std::endl;
(*c) = value;
+ //con_debug << "cvar::set " << name << " " << cvar->text() << std::endl;
return c;
}
@@ -120,8 +120,8 @@ Cvar set(const char *name, float value, int flags)
c = new Cvar_t(flags);
registry[std::string(name)] = c;
}
- con_debug << "cvar::set " << name << " " << value << std::endl;
(*c) = value;
+ //con_debug << "cvar::set " << name << " " << cvar->text() << std::endl;
return c;
}
@@ -156,7 +156,7 @@ Cvar find(const char *name)
void list()
{
- con_print << "-- listcvar -----------------" << std::endl;
+ con_print << "Registered variables:" << std::endl;
std::map<std::string, Cvar>::iterator it;
for (it = registry.begin(); it != registry.end(); it++) {
diff --git a/src/core/func.cc b/src/core/func.cc
index c72faea..064f77d 100644
--- a/src/core/func.cc
+++ b/src/core/func.cc
@@ -43,7 +43,7 @@ Func find(const std::string &functionname)
void list()
{
- con_print << "-- listfunc -----------------" << std::endl;
+ con_print << "Registered functions:" << std::endl;
std::map<std::string, Func>::iterator it;
for (it = registry.begin(); it != registry.end(); it++) {
con_print << " " << (*it).first << std::endl;