Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/client/client.cc5
-rw-r--r--src/client/video.cc2
-rw-r--r--src/filesystem/inifile.cc3
-rw-r--r--src/game/base/cargo.cc4
-rw-r--r--src/game/base/cargopod.cc5
-rw-r--r--src/game/base/game.cc34
-rw-r--r--src/game/base/game.h3
-rw-r--r--src/game/base/shipmodel.cc2
-rw-r--r--src/game/intro/intro.cc2
-rw-r--r--src/ui/ui.cc283
-rw-r--r--src/ui/ui.h14
11 files changed, 183 insertions, 174 deletions
diff --git a/src/client/client.cc b/src/client/client.cc
index a40023b..318a0d4 100644
--- a/src/client/client.cc
+++ b/src/client/client.cc
@@ -415,13 +415,10 @@ void Client::func_list_ui(std::string const &args)
void Client::func_ui_restart(std::string const &args)
{
if (ui::root()) {
- ui::root()->load_menus();
ui::root()->load_settings();
- ui::root()->apply_render_options();
}
}
-
void Client::func_ui_console(std::string const &args)
{
ui::console()->toggle();
@@ -469,9 +466,7 @@ void Client::func_ui(std::string const &args)
} else if (command.compare("visible") == 0) {
ui::root()->list_visible();
} else if (command.compare("restart") == 0) {
- ui::root()->load_menus();
ui::root()->load_settings();
- ui::root()->apply_render_options();
} else {
func_ui_help();
}
diff --git a/src/client/video.cc b/src/client/video.cc
index 5610f36..cd675f7 100644
--- a/src/client/video.cc
+++ b/src/client/video.cc
@@ -200,7 +200,7 @@ bool init()
render::init(width, height);
// apply render options
- ui::root()->apply_render_options();
+ ui::root()->load_settings();
// initialize target drawer
targets::init();
diff --git a/src/filesystem/inifile.cc b/src/filesystem/inifile.cc
index 8cf186c..e82de41 100644
--- a/src/filesystem/inifile.cc
+++ b/src/filesystem/inifile.cc
@@ -53,8 +53,7 @@ bool IniFile::open(const char *ininame)
section_current = "";
line_number = 0;
- std::string inifile_name("ini/");
- inifile_name.append(ininame);
+ std::string inifile_name(ininame);
inifile_name.append(".ini");
inifile_stream.open(inifile_name);
diff --git a/src/game/base/cargo.cc b/src/game/base/cargo.cc
index daf4ac2..c7f2492 100644
--- a/src/game/base/cargo.cc
+++ b/src/game/base/cargo.cc
@@ -27,7 +27,7 @@ bool Cargo::init()
Cargo::cargo_infotype = new core::InfoType("cargo");
filesystem::IniFile cargoini;
- cargoini.open("cargo");
+ cargoini.open("ini/cargo");
if (!cargoini.is_open()) {
con_error << "Could not open " << cargoini.name() << "!" << std::endl;
return false;
@@ -80,7 +80,7 @@ bool Cargo::init()
if (cargoini.got_section("cargo")) {
cargo = new Cargo();
-
+
} else if (cargoini.got_section()) {
cargoini.unknown_section();
}
diff --git a/src/game/base/cargopod.cc b/src/game/base/cargopod.cc
index 6581b75..5ea4105 100644
--- a/src/game/base/cargopod.cc
+++ b/src/game/base/cargopod.cc
@@ -19,9 +19,8 @@ CargoPod::CargoPod() : EntityDynamic()
set_flag(core::Entity::KeepAlive);
set_keepalive_timeout(Game::g_keepalive ? Game::g_keepalive->value() : 0);
- // FIXME hardcoded modelname
- set_modelname("maps/cargo/pod");
-
+ if (Default::podmodel)
+ set_modelname(Default::podmodel->name());
set_mass(radius());
// activate physics
diff --git a/src/game/base/game.cc b/src/game/base/game.cc
index 9d2dcd0..73fd9ad 100644
--- a/src/game/base/game.cc
+++ b/src/game/base/game.cc
@@ -34,6 +34,7 @@ namespace game
// default player settings
core::Zone *Default::zone = 0;
core::Entity *Default::view = 0;
+model::Model *Default::podmodel = 0;
ShipModel *Default::shipmodel = 0;
long Default::credits = 0;
@@ -43,6 +44,7 @@ void Default::clear()
view = 0;
shipmodel = 0;
credits = 0;
+ podmodel = 0;
}
/* -- class Game static members ----------------------------------- */
@@ -827,7 +829,7 @@ Game::Game() : core::Module("Project::OSiRiON", true)
}
// load game default settings
- if (!load_defaults()) {
+ if (!load_settings()) {
abort();
return;
}
@@ -900,15 +902,22 @@ Game::Game() : core::Module("Project::OSiRiON", true)
Game::~Game()
{
g_impulsespeed = 0;
+ g_jumppointrange = 0;
+ g_devel = 0;
+ g_damping = 0;
+ g_keepalive = 0;
// game functions are automaticly removed
+ // FIXME move cleanup sequence to core::
// we explicity clear game data to prevent bullet from beeing confused
core::game()->clear();
+
+ Default::clear();
}
bool Game::load_world()
{
- std::string inifilename("world");
+ std::string inifilename("ini/world");
filesystem::IniFile worldini;
worldini.open(inifilename);
@@ -977,7 +986,7 @@ bool Game::load_zone(core::Zone *zone)
using math::Vector3f;
using math::Color;
- std::string inifilename("zones/");
+ std::string inifilename("ini/zones/");
inifilename.append(zone->label());
filesystem::IniFile zoneini;
@@ -1394,12 +1403,10 @@ bool Game::generate_entity_menus(core::Entity *entity)
}
// load game defaults settings
-bool Game::load_defaults()
+bool Game::load_settings()
{
- Default::clear();
-
filesystem::IniFile inifile;
- inifile.open("game");
+ inifile.open("ini/game");
if (!inifile.is_open()) {
con_error << "Could not open " << inifile.name() << "!" << std::endl;
return false;
@@ -1414,6 +1421,8 @@ bool Game::load_defaults()
if (inifile.got_section("player")) {
continue;
+ } else if (inifile.got_section("cargo")) {
+ continue;
} else {
inifile.unknown_section();
}
@@ -1421,6 +1430,7 @@ bool Game::load_defaults()
} else if (inifile.got_key()) {
if (inifile.in_section("player")) {
+
if (inifile.got_key_long("credits", l)) {
Default::credits = l;
} else if (inifile.got_key_string("zone", str)) {
@@ -1429,6 +1439,16 @@ bool Game::load_defaults()
} else if (inifile.got_key_string("ship", str)) {
aux::to_label(str);
Default::shipmodel = ShipModel::find(str);
+ } else {
+ inifile.unkown_key();
+ }
+
+ } else if (inifile.in_section("cargo")) {
+
+ if (inifile.got_key_string("model", str)) {
+ Default::podmodel = model::Model::load(str);
+ } else {
+ inifile.unkown_key();
}
}
}
diff --git a/src/game/base/game.h b/src/game/base/game.h
index 1042367..d879a30 100644
--- a/src/game/base/game.h
+++ b/src/game/base/game.h
@@ -52,6 +52,7 @@ public:
static core::Zone *zone;
static core::Entity *view;
static ShipModel *shipmodel;
+ static model::Model *podmodel;
static long credits;
static void clear();
@@ -104,7 +105,7 @@ private:
bool load_ships();
- bool load_defaults();
+ bool load_settings();
/* ---- engine functions ----------------------------------- */
diff --git a/src/game/base/shipmodel.cc b/src/game/base/shipmodel.cc
index de68413..cd69c5b 100644
--- a/src/game/base/shipmodel.cc
+++ b/src/game/base/shipmodel.cc
@@ -26,7 +26,7 @@ bool ShipModel::init()
using math::Color;
filesystem::IniFile shipsini;
- shipsini.open("ships");
+ shipsini.open("ini/ships");
if (!shipsini.is_open()) {
con_error << "Could not open " << shipsini.name() << "!" << std::endl;
return false;
diff --git a/src/game/intro/intro.cc b/src/game/intro/intro.cc
index f2da493..8d5577b 100644
--- a/src/game/intro/intro.cc
+++ b/src/game/intro/intro.cc
@@ -35,7 +35,7 @@ Intro::Intro() : core::Module("Project::OSiRiON", false)
bool Intro::load_world()
{
- std::string filename("intro");
+ std::string filename("ini/intro");
filesystem::IniFile ini;
ini.open(filename);
diff --git a/src/ui/ui.cc b/src/ui/ui.cc
index 5faf9fd..de881cb 100644
--- a/src/ui/ui.cc
+++ b/src/ui/ui.cc
@@ -48,9 +48,6 @@ void init()
con_warn << "User interface already initialized!" << std::endl;
return;
}
-
- global_ui->load_menus();
- global_ui->load_settings();
}
void shutdown()
@@ -100,144 +97,21 @@ UI::~UI()
delete ui_font_large;
}
-void UI::load_menus()
+void UI::load_settings()
{
ui_active_menu = 0;
-
+ ui_mouse_focus = this;
+
+ // clear any existing menus
Menus::iterator it;
for (it = ui_menus.begin(); it != ui_menus.end(); it++) {
Window *menu = (*it);
remove_child(menu);
}
ui_menus.clear();
-
- std::string filename("menu");
- filesystem::IniFile ini;
- ini.open(filename);
- if (!ini.is_open()) {
- con_error << "Could not open " << ini.name() << std::endl;
- } else {
- std::string strval;
- Button *button = 0;
- Label *label = 0;
- Menu *menu = 0;
-
- while (ini.getline()) {
- if (ini.got_section()) {
- if (ini.got_section("menu")) {
- menu = new Menu(this);
- add_menu(menu);
- continue;
- } else if (menu) {
- if (ini.got_section("button")) {
- button = menu->add_button();
-
- } else if (ini.got_section("label")) {
- label = menu->add_label();
-
- } else {
- ini.unknown_section();
- }
- } else {
- ini.unknown_section();
- }
- } else if (menu && ini.got_key()) {
- if (ini.in_section("menu")) {
- if (ini.got_key_string("label", strval)) {
- aux::to_label(strval);
- menu->set_label(strval);
- } else if (ini.got_key_string("background", strval)) {
- menu->set_background_texture(strval);
- } else {
- ini.unkown_key();
- }
- } else if (ini.in_section("button")) {
- if (ini.got_key_string("text", strval)) {
- aux::strip_quotes(strval);
- button->set_text(strval);
-
- } else if (ini.got_key_string("command", strval)) {
- for (size_t i = 0; i <= strval.size(); i++) {
- if (strval[i] == ',') strval[i] = ';';
- }
- aux::strip_quotes(strval);
- button->set_command(strval);
-
- } else if (ini.got_key_string("align", strval)) {
- aux::to_label(strval);
- if (strval.compare("left") == 0) {
- button->set_alignment(AlignLeft | AlignVCenter);
- } else if (strval.compare("center") == 0) {
- button->set_alignment(AlignCenter);
- } else if (strval.compare("right") == 0) {
- button->set_alignment(AlignRight | AlignVCenter);
- } else {
- ini.unknown_value();
- }
- } else {
- ini.unkown_key();
- }
- } else if (ini.in_section("label")) {
- if (ini.got_key_string("text", strval)) {
- label->set_text(strval);
- } else if (ini.got_key_string("align", strval)) {
- aux::to_label(strval);
- if (strval.compare("left") == 0) {
- label->set_alignment(AlignLeft | AlignHCenter);
- } else if (strval.compare("center") == 0) {
- label->set_alignment(AlignCenter);
- } else if (strval.compare("right") == 0) {
- label->set_alignment(AlignRight | AlignHCenter);
- } else {
- ini.unknown_value();
- }
- } else {
- ini.unkown_key();
- }
- }
-
- }
- }
-
- con_debug << " " << ini.name() << " " << ui_menus.size() << " menus" << std::endl;
- ini.close();
- }
-
- // fallback main menu
- if (!find_menu("main")) {
- con_warn << "menu 'main' not found, using default" << std::endl;
- Menu *menu = new Menu(this, "main");
- menu->add_label("Main Menu");
- menu->add_button("Connect", "connect");
- menu->add_button("Quit", "quit");
- }
-
- // fallback game menu
- if (!find_menu("game")) {
- con_warn << "menu 'game' not found, using default" << std::endl;
- Menu *menu = new Menu(this, "game");
- menu->add_label("Game Menu");
- menu->add_button("Disconnect", "disconnect");
- menu->add_button("Quit", "quit");
- }
-
- // fallback join menu
- if (!find_menu("join")) {
- con_warn << "menu 'join' not found, using default" << std::endl;
- Menu *menu = new Menu(this, "join");
- menu->add_label("Join Menu");
- menu->add_button("Join", "join; menu hide");
- menu->add_button("Game menu", "menu game");
- }
-}
-
-
-void UI::load_settings()
-{
-
- ui_mouse_focus = this;
-
- std::string filename("ui");
+
+ // open ui.ini
+ std::string filename("ini/ui");
filesystem::IniFile ini;
ini.open(filename);
@@ -248,6 +122,10 @@ void UI::load_settings()
std::string strval;
math::Color color;
+
+ Button *button = 0;
+ Label *label = 0;
+ Menu *menu = 0;
float w = elementsize.width();
float h = elementsize.height();
@@ -257,18 +135,53 @@ void UI::load_settings()
while (ini.getline()) {
if (ini.got_section()) {
+
if (ini.got_section("ui")) {
+ menu = 0;
continue;
+ // section default colors
} else if (ini.got_section("colors")) {
+ menu = 0;
continue;
+ // section hud configuration
} else if (ini.got_section("hud")) {
+ menu = 0;
continue;
+ // section text colors
} else if (ini.got_section("text")) {
+ menu = 0;
continue;
+ // section menu
+ } else if (ini.got_section("menu")) {
+ label = 0;
+ button = 0;
+ menu = new Menu(this);
+ add_menu(menu);
+ continue;
+
+ // menu button
+ } else if (ini.got_section("button")) {
+
+ if (!menu) {
+ ini.unknown_error("button section outside menu defintion");
+ } else {
+ button = menu->add_button();
+ }
+
+ // menu label
+ } else if (ini.got_section("label")) {
+
+ if (!menu) {
+ ini.unknown_error("label section outside menu defintion");
+ } else {
+ label = menu->add_label();
+ }
+
+
} else {
ini.unknown_section();
continue;
@@ -349,24 +262,112 @@ void UI::load_settings()
} else if (ini.got_key_color("error", color)) {
ui_palette->set_error(color);
}
+
+ // menu definitions
+
+ } else if (menu) {
+
+ if (ini.in_section("menu")) {
+
+ if (ini.got_key_string("label", strval)) {
+ aux::to_label(strval);
+ menu->set_label(strval);
+ } else if (ini.got_key_string("background", strval)) {
+ menu->set_background_texture(strval);
+ } else {
+ ini.unkown_key();
+ }
+
+ } else if (ini.in_section("button")) {
+
+ if (ini.got_key_string("text", strval)) {
+ aux::strip_quotes(strval);
+ button->set_text(strval);
+
+ } else if (ini.got_key_string("command", strval)) {
+ for (size_t i = 0; i <= strval.size(); i++) {
+ if (strval[i] == ',') strval[i] = ';';
+ }
+ aux::strip_quotes(strval);
+ button->set_command(strval);
+
+ } else if (ini.got_key_string("align", strval)) {
+ aux::to_label(strval);
+ if (strval.compare("left") == 0) {
+ button->set_alignment(AlignLeft | AlignVCenter);
+ } else if (strval.compare("center") == 0) {
+ button->set_alignment(AlignCenter);
+ } else if (strval.compare("right") == 0) {
+ button->set_alignment(AlignRight | AlignVCenter);
+ } else {
+ ini.unknown_value();
+ }
+ } else {
+ ini.unkown_key();
+ }
+
+ } else if (ini.in_section("label")) {
+
+ if (ini.got_key_string("text", strval)) {
+ label->set_text(strval);
+ } else if (ini.got_key_string("align", strval)) {
+ aux::to_label(strval);
+ if (strval.compare("left") == 0) {
+ label->set_alignment(AlignLeft | AlignHCenter);
+ } else if (strval.compare("center") == 0) {
+ label->set_alignment(AlignCenter);
+ } else if (strval.compare("right") == 0) {
+ label->set_alignment(AlignRight | AlignHCenter);
+ } else {
+ ini.unknown_value();
+ }
+ } else {
+ ini.unkown_key();
+ }
+ }
+
}
}
}
-
- ini.close();
-}
-
-void UI::apply_render_options()
-{
- //con_debug << " initializing text colors" << std::endl;
- // apply palette colors
+
+ // apply palette colors to the render subsystem
Paint::assign_system_color('N', palette()->text());
Paint::assign_system_color('D', palette()->debug());
Paint::assign_system_color('B', palette()->bold());
Paint::assign_system_color('F', palette()->fancy());
Paint::assign_system_color('W', palette()->warning());
Paint::assign_system_color('E', palette()->error());
+
+ con_debug << " " << ini.name() << " " << ui_menus.size() << " menus" << std::endl;
+
+ // fallback main menu
+ if (!find_menu("main")) {
+ con_warn << "menu 'main' not found, using default" << std::endl;
+ Menu *menu = new Menu(this, "main");
+ menu->add_label("Main Menu");
+ menu->add_button("Connect", "connect");
+ menu->add_button("Quit", "quit");
+ }
+ // fallback game menu
+ if (!find_menu("game")) {
+ con_warn << "menu 'game' not found, using default" << std::endl;
+ Menu *menu = new Menu(this, "game");
+ menu->add_label("Game Menu");
+ menu->add_button("Disconnect", "disconnect");
+ menu->add_button("Quit", "quit");
+ }
+
+ // fallback join menu
+ if (!find_menu("join")) {
+ con_warn << "menu 'join' not found, using default" << std::endl;
+ Menu *menu = new Menu(this, "join");
+ menu->add_label("Join Menu");
+ menu->add_button("Join", "join; menu hide");
+ menu->add_button("Game menu", "menu game");
+ }
+
+ ini.close();
}
void UI::list() const
diff --git a/src/ui/ui.h b/src/ui/ui.h
index c340eb8..c611a26 100644
--- a/src/ui/ui.h
+++ b/src/ui/ui.h
@@ -34,15 +34,6 @@ public:
/// list meus
void list_menus() const;
- /// load menus from menu.ini
- void load_menus();
-
- /// load settings from ui.ini
- void load_settings();
-
- /// apply UI options to the render engine
- void apply_render_options();
-
/// make a window the active window
void show_menu(const char *label);
@@ -81,6 +72,9 @@ public:
/// run a user interface frame
void frame();
+ /// load settings from ui.ini
+ void load_settings();
+
/* -- fonts ------------------------------------------------ */
/// default small font
@@ -121,7 +115,7 @@ protected:
/// handle key release events
virtual bool on_keyrelease(const int key, const unsigned int modifier);
-private:
+private:
void draw_pointer();
Palette *ui_palette;