Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/client/client.cc26
-rw-r--r--src/client/input.cc3
-rw-r--r--src/client/keyboard.cc9
-rw-r--r--src/client/testmodelview.cc44
-rw-r--r--src/client/testmodelview.h3
-rw-r--r--src/core/application.cc9
-rw-r--r--src/core/commandbuffer.cc10
-rw-r--r--src/core/commandbuffer.h1
-rw-r--r--src/core/gameserver.cc4
-rwxr-xr-xsrc/ui/modelview.cc4
10 files changed, 70 insertions, 43 deletions
diff --git a/src/client/client.cc b/src/client/client.cc
index ec2d002..97cfc91 100644
--- a/src/client/client.cc
+++ b/src/client/client.cc
@@ -113,12 +113,12 @@ void Client::init(int count, char **arguments)
quit(1);
}
- // initialize input
- input::init();
-
// initialize audio
audio::init();
+ // initialize input
+ input::init();
+
// add engine functions
core::Func *func = 0;
@@ -224,7 +224,7 @@ void Client::frame(unsigned long timestamp)
core::Application::frame(timestamp);
if (!connected()) {
- std::string module_label(core::Loader::label());
+ const std::string module_label(core::Loader::label());
// load the intro if nothing is running
if (load("intro")) {
@@ -589,6 +589,24 @@ void Client::func_menu(std::string const &args)
void Client::func_testmodel(std::string const &args)
{
+ // if testmodel is called from the command line, no module has been loaded yet
+ if (!client()->connected()) {
+ const std::string module_label(core::Loader::label());
+
+ // load the intro if nothing is running
+ if (client()->load("intro")) {
+ client()->connect("");
+ if (module_label.size())
+ client()->load(module_label);
+ }
+ }
+
+ if (!client()->connected()) {
+ client()->client_testmodelview->hide();
+ ui::console()->show();
+ return;
+ }
+
std::string modelname(args);
aux::trim(modelname);
diff --git a/src/client/input.cc b/src/client/input.cc
index 0412093..3741e15 100644
--- a/src/client/input.cc
+++ b/src/client/input.cc
@@ -279,6 +279,9 @@ void init()
input_grab = core::Cvar::get("input_grab", 1.0f, core::Cvar::Archive);
input_grab->set_info("[bool] grab input");
+ if (!input_grab->value()) {
+ SDL_WM_GrabInput(SDL_GRAB_OFF);
+ }
core::Func *func = 0;
func = core::Func::add("ui_control", func_ui_control);
diff --git a/src/client/keyboard.cc b/src/client/keyboard.cc
index 176e310..7486ff3 100644
--- a/src/client/keyboard.cc
+++ b/src/client/keyboard.cc
@@ -317,13 +317,12 @@ void Keyboard::load_binds()
char line[MAXCMDSIZE];
while (ifs.getline(line, MAXCMDSIZE - 1)) {
- if (line[0] && line[0] != '#' && line[0] != ';')
- core::cmd() << line << '\n';
+ if (line[0] && line[0] != '#' && line[0] != ';') {
+ core::CommandBuffer::exec(line);
+ }
}
-
- // execute commands in the buffer
- core::CommandBuffer::exec();
}
+
Key * Keyboard::release(unsigned int sym)
{
Key *key = find(sym);
diff --git a/src/client/testmodelview.cc b/src/client/testmodelview.cc
index 4164d6c..40ae1aa 100644
--- a/src/client/testmodelview.cc
+++ b/src/client/testmodelview.cc
@@ -36,28 +36,7 @@ TestModelView::~TestModelView()
void TestModelView::set_modelname(const std::string & modelname)
{
- model::Model *model = model::Model::load(modelname);
-
- std::ostringstream str;
- str << modelname << '\n';
-
- if (model) {
- size_t frags = 0;
-
- for (model::Model::Groups::const_iterator git = model->groups().begin(); git != model->groups().end(); git++) {
- frags += (*git)->size();
- }
- str << '\n';
- str << "tris: " << model->model_tris_count << '\n';
- str << "quads: " << model->model_quad_count << '\n';
- str << "fragments: " << frags << '\n';
-
- testmodelview_modelview->set_modelname(modelname);
- } else {
- testmodelview_modelview->set_modelname("");
- testmodelview_modelview->set_background(true);
- }
- testmodelview_text->set_text(str.str());
+ testmodelview_modelview->set_modelname(modelname);
}
void TestModelView::show()
@@ -102,6 +81,27 @@ void TestModelView::draw_background()
ui::Paint::draw_rectangle(global_location(), size());
}
+void TestModelView::draw()
+{
+ model::Model *model = model::Model::find(testmodelview_modelview->modelname());
+
+ std::ostringstream str;
+ str << testmodelview_modelview->modelname() << '\n';
+
+ if (model) {
+ size_t frags = 0;
+
+ for (model::Model::Groups::const_iterator git = model->groups().begin(); git != model->groups().end(); git++) {
+ frags += (*git)->size();
+ }
+ str << '\n';
+ str << "tris: " << model->model_tris_count << '\n';
+ str << "quads: " << model->model_quad_count << '\n';
+ str << "fragments: " << frags << '\n';
+ }
+ testmodelview_text->set_text(str.str());
+}
+
bool TestModelView::on_emit(Widget *sender, const Event event, void *data)
{
if (event == ui::Widget::EventButtonClicked) {
diff --git a/src/client/testmodelview.h b/src/client/testmodelview.h
index 6b38df6..6a3d9f3 100644
--- a/src/client/testmodelview.h
+++ b/src/client/testmodelview.h
@@ -31,6 +31,9 @@ public:
virtual void hide();
protected:
+ /// update model statistics
+ virtual void draw();
+
/// resize te testmodelview
virtual void resize();
diff --git a/src/core/application.cc b/src/core/application.cc
index f21dcad..15179c9 100644
--- a/src/core/application.cc
+++ b/src/core/application.cc
@@ -371,11 +371,8 @@ void Application::load_config()
char line[MAXCMDSIZE];
while (ifs.getline(line, MAXCMDSIZE - 1)) {
if (line[0] && line[0] != '#' && line[0] != ';')
- cmd() << line << '\n';
+ CommandBuffer::exec(line);
}
-
- // execute commands in the buffer
- CommandBuffer::exec();
}
void Application::load_autoexec()
@@ -409,10 +406,8 @@ void Application::load_autoexec()
char line[MAXCMDSIZE];
while (ifs.getline(line, MAXCMDSIZE - 1)) {
if (line[0] && line[0] != '#' && line[0] != ';')
- cmd() << line << '\n';
+ CommandBuffer::exec(line);
}
-
- CommandBuffer::exec();
}
}
diff --git a/src/core/commandbuffer.cc b/src/core/commandbuffer.cc
index 40971cc..58fe6be 100644
--- a/src/core/commandbuffer.cc
+++ b/src/core/commandbuffer.cc
@@ -316,7 +316,15 @@ void CommandBuffer::exec(std::string const &cmdline)
if (!cmdline.size())
return;
- std::istringstream cmdstream(cmdline);
+ std::string cleaned;
+
+ for (size_t i = 0; i < cmdline.size(); i++) {
+ if (cmdline[i] != '"') {
+ cleaned += cmdline[i];
+ }
+ }
+
+ std::istringstream cmdstream(cleaned);
std::string command;
if (!(cmdstream >> command))
diff --git a/src/core/commandbuffer.h b/src/core/commandbuffer.h
index c8024ba..5ecfeee 100644
--- a/src/core/commandbuffer.h
+++ b/src/core/commandbuffer.h
@@ -43,7 +43,6 @@ public:
/// the global command buffer
static std::stringstream cmdbuf;
-private:
static void exec(std::string const & cmdline);
};
diff --git a/src/core/gameserver.cc b/src/core/gameserver.cc
index e07774d..cb1e66d 100644
--- a/src/core/gameserver.cc
+++ b/src/core/gameserver.cc
@@ -684,11 +684,9 @@ void GameServer::load_config()
char line[MAXCMDSIZE];
while (ifs.getline(line, MAXCMDSIZE - 1)) {
if (line[0] && line[0] != '#' && line[0] != ';')
- cmd() << line << '\n';
+ CommandBuffer::exec(line);
}
- // execute commands in the buffer
- CommandBuffer::exec();
}
}
diff --git a/src/ui/modelview.cc b/src/ui/modelview.cc
index e715119..dc6ddfc 100755
--- a/src/ui/modelview.cc
+++ b/src/ui/modelview.cc
@@ -139,6 +139,10 @@ void ModelView::draw()
return;
}
+ if (!core::application()->connected() || !core::game()->time()) {
+ return;
+ }
+
Paint::set_color(1.0f, 1.0f, 1.0f);
model::Model *model = model::Model::load(modelview_modelname);
if (!model) {