00001
00002
00003 #include <iostream>
00004 #include <iterator>
00005 #include <stdio.h>
00006 #include "vamosworld.h"
00007 #include "controls.h"
00008 #include "mouse.h"
00009 #include "utility.h"
00010 #include "gui/widget.h"
00011 #include "gui/page.h"
00012 #include "gui/gui.h"
00013 #include "gui/button.h"
00014 #include "gui/calibrate.h"
00015 #include "gui/controlgrab.h"
00016 #include "gui/image.h"
00017 #include "gui/label.h"
00018 #include "gui/multi_image.h"
00019 #include "gui/slider.h"
00020 #include "gui/spinning_car.h"
00021 #include "gui/textbox.h"
00022 #include "gui/toggle.h"
00023 #include "gui/wheel.h"
00024
00025 using namespace VGUI;
00026
00027 extern bool verbose_output;
00028
00029
00030 Page::Page()
00031 {
00032 cout << "OOPS! tried to create a page without a filename. Not attempting load/init." << endl;
00033 }
00034
00035 Page::Page( string filename )
00036 {
00037 path = filename;
00038 menu_file.Load( path );
00039 menu_file.SuppressError( !verbose_output );
00040 num_widgets = 0;
00041 default_obj = cur_obj = cancel_obj = cur_tab = 0;
00042 has_changes = is_dialog = l_pressed = r_pressed = false;
00043 name = tab_text = "";
00044 clicked_obj = 10000;
00045 Init();
00046 }
00047
00048 Page::~Page()
00049 {
00050 menu_file.Clear();
00051 for( unsigned int i = 0; i < page_objects.size(); i++ )
00052 {
00053 delete page_objects[i];
00054 }
00055 page_objects.clear();
00056 }
00057
00058 void Page::Init()
00059 {
00060 string background_filename;
00061 Widget* wgt;
00062 Button* btn;
00063 Image* img;
00064 MultiImage* mimg;
00065 Label* lbl;
00066 Slider* sld;
00067 Toggle* tgl;
00068 Wheel<int>* iwhl;
00069 Wheel2<int, int>* iiwhl;
00070 Wheel<float>* fwhl;
00071 Wheel<string>* swhl;
00072 SpinningCar* scar;
00073 TextBox* tbox;
00074 ControlGrab* cgrb;
00075 Calibrate* cal;
00076
00077
00078 int n_wgts;
00079
00080 if( verbose_output ) cout << endl << "Menu file: " << path << endl << "=================================" << endl;
00081
00082
00083 if( menu_file.GetParam( ".name", name ) )
00084 {
00085 if( verbose_output ) cout << "Name: " << name << endl;
00086 }
00087 else
00088 {
00089 if( verbose_output ) cout << "Name not found. Page is nameless..." << endl;
00090 }
00091
00092
00093 if( !menu_file.GetParam( ".widgets", n_wgts ) )
00094 {
00095 if( verbose_output ) cout << "could not find number of widgets, assuming 10" << endl;
00096 num_widgets = 10;
00097 }
00098 else
00099 {
00100 num_widgets = n_wgts;
00101 if( verbose_output ) cout << "Number of widgets in this file: " << num_widgets << endl;
00102 }
00103
00104
00105 if( !menu_file.GetParam( ".background", background_filename ) )
00106 {
00107 if( verbose_output ) cout << "cound not find background image for this page, default to gui/box.png" << endl;
00108 background_filename = "box.png";
00109 }
00110 else
00111 {
00112 if( verbose_output ) cout << "Background image: " << background_filename << endl;
00113 }
00114 background.Load( settings.GetSkinPath() + "/textures/" + background_filename, false );
00115
00116
00117 if( !menu_file.GetParam( ".tab_text", tab_text ) )
00118 {
00119 if( verbose_output ) cout << "cound not find tab text, assuming none." << endl;
00120 tab_text = "";
00121 }
00122 else
00123 {
00124 if( verbose_output ) cout << "tab text: " << tab_text << endl;
00125 }
00126
00127
00128 if( !menu_file.GetParam( ".dialog", is_dialog ) )
00129 {
00130 if( verbose_output ) cout << "dialog setting not found, default to false." << endl;
00131 is_dialog = false;
00132 }
00133 else
00134 {
00135 if( verbose_output ) cout << "Dialog: " << is_dialog << endl;
00136 }
00137
00138 int n_tabs = 0;
00139
00140 if( !menu_file.GetParam( ".tabs", n_tabs ) )
00141 {
00142 if( verbose_output ) cout << "number of tabs not found, default to 0." << endl;
00143 num_tabs = 0;
00144 }
00145 else
00146 {
00147 num_tabs = n_tabs;
00148 if( verbose_output ) cout << "Tabs: " << num_tabs << endl;
00149
00150 tab_active.Load( "gui/widgets/tab_active.png", false );
00151 tab_inactive.Load( "gui/widgets/tab_inactive.png", false );
00152 tab_page_background.Load( "gui/widgets/tab_page_background.png", false );
00153 char tab_txt[20];
00154 string tab_str, tab_name;
00155
00156 for( unsigned int j = 0; j < num_tabs; j++ )
00157 {
00158 sprintf( tab_txt, "tab-%02d", j );
00159 tab_str = tab_txt;
00160 if( !menu_file.GetParam( "." + tab_str, tab_name ) )
00161 {
00162 if( verbose_output ) cout << "Could not find " << tab_str << ", skipping." << endl;
00163 }
00164 else
00165 {
00166
00167 tabs.push_back( new Page( settings.GetFullDataPath( "lists/new-menus/" + tab_name ) ) );
00168 if( verbose_output ) cout << "Added tab: " << tab_name << endl;
00169 }
00170 }
00171 }
00172
00173 for( unsigned int n = 0; n < num_widgets; n++ )
00174 {
00175 char w[20];
00176 sprintf( w, "widget-%02d", n );
00177 string wgt_id = w;
00178 string wgt_type, wgt_name, wgt_text, wgt_center_double, wgt_width_txt, wgt_height_txt, wgt_setting, wgt_tip, wgt_hook;
00179 string value_source = "manual";
00180 float x_val = 0.5;
00181 float y_val = 0.5;
00182 float wgt_color[3] = {1.0, 1.0, 1.0};
00183 Location wgt_center;
00184 bool wgt_enabled, wgt_selected, wgt_default, wgt_cancel;
00185 int wgt_font_size;
00186 wgt = new Widget();
00187
00188
00189 if( menu_file.GetParam( wgt_id + ".name", wgt_name ) )
00190 {
00191 wgt->SetName( wgt_name );
00192 if( verbose_output ) cout << wgt_id << ": name: " << wgt_name << endl;
00193 }
00194 else
00195 {
00196 if( verbose_output ) cout << wgt_id << ": name not found. Can't use this widget, skipping." << endl;
00197 break;
00198 }
00199
00200
00201 if( menu_file.GetParam( wgt_id + ".type", wgt_type ) )
00202 {
00203 wgt->SetType( wgt_type );
00204 if( verbose_output ) cout << wgt_id << ": type: " << wgt_type << endl;
00205
00206
00207 if( !menu_file.GetParam( wgt_id + ".text", wgt_text ) )
00208 {
00209 if( verbose_output ) cout << wgt_id << ": text not found, using [empty]." << endl;
00210 wgt_text = "";
00211 }
00212 else
00213 {
00214 wgt_text = _(wgt_text);
00215 if( verbose_output ) cout << wgt_id << ": text: " << wgt_text << endl;
00216 }
00217 wgt->SetText( wgt_text );
00218
00219
00220 if( !menu_file.GetParam( wgt_id + ".fontsize", wgt_font_size ) )
00221 {
00222 if( verbose_output ) cout << wgt_id << ": font size not found, using 5." << endl;
00223 wgt_font_size = 5;
00224 }
00225 else
00226 {
00227 if( verbose_output ) cout << wgt_id << ": fontsize: " << wgt_font_size << endl;
00228 }
00229 wgt->SetFontSize( wgt_font_size );
00230
00231
00232 if( !menu_file.GetParam( wgt_id + ".color", wgt_color ) )
00233 {
00234 if( verbose_output ) cout << wgt_id << ": color not found, using white." << endl;
00235 wgt_color[0] = 1.0;
00236 wgt_color[1] = 1.0;
00237 wgt_color[2] = 1.0;
00238 }
00239 else
00240 {
00241 if( verbose_output ) cout << wgt_id << ": color: " << wgt_color[0] << "," << wgt_color[1] << "," << wgt_color[2] << endl;
00242 }
00243 wgt->SetColor( wgt_color[0], wgt_color[1], wgt_color[2] );
00244
00245
00246 if( menu_file.GetParam( wgt_id + ".center", wgt_center_double ) )
00247 {
00248 if( EOF == sscanf( wgt_center_double.c_str(), "%f, %f", &x_val, &y_val ) )
00249 {
00250 if( verbose_output ) cout << wgt_id << ": center location could not be read, using \"0.5, 0.5\"." << endl;
00251 }
00252 else
00253 {
00254 if( verbose_output ) cout << wgt_id << ": location: " << x_val << ", " << y_val << endl;
00255 }
00256 }
00257 else
00258 {
00259 if( verbose_output ) cout << wgt_id << ": center location not found, using \"0.5, 0.5\"." << endl;
00260 }
00261 wgt_center = Location( x_val, y_val );
00262 wgt->SetCenter( wgt_center );
00263
00264
00265 if( menu_file.GetParam( wgt_id + ".width", wgt_width_txt ) )
00266 {
00267 float width_val;
00268 if( wgt_width_txt == "auto" )
00269 {
00270 if( verbose_output ) cout << wgt_id << ": width: " << wgt_width_txt << endl;
00271 wgt->SetWidthAuto( true );
00272 }
00273 else
00274 {
00275 if( EOF == sscanf( wgt_width_txt.c_str(), "%f", &width_val ) )
00276 {
00277 if( verbose_output ) cout << wgt_id << ": width could not be read, default to auto." << endl;
00278 wgt->SetWidthAuto( true );
00279 }
00280 else
00281 {
00282 if( verbose_output ) cout << wgt_id << ": width: " << width_val << endl;
00283 wgt->SetRelWidth( width_val );
00284 wgt->SetWidthAuto( false );
00285 }
00286 }
00287 }
00288 else
00289 {
00290 if( verbose_output ) cout << wgt_id << ": width not found, default to auto." << endl;
00291 wgt->SetWidthAuto( true );
00292 }
00293
00294
00295 if( menu_file.GetParam( wgt_id + ".height", wgt_height_txt ) )
00296 {
00297 float height_val;
00298 if( wgt_height_txt == "auto" )
00299 {
00300 if( verbose_output ) cout << wgt_id << ": height: " << wgt_height_txt << endl;
00301 wgt->SetHeightAuto( true );
00302 }
00303 else
00304 {
00305 if( EOF == sscanf( wgt_height_txt.c_str(), "%f", &height_val ) )
00306 {
00307 if( verbose_output ) cout << wgt_id << ": height could not be read, default to auto." << endl;
00308 wgt->SetHeightAuto( true );
00309 }
00310 else
00311 {
00312 if( verbose_output ) cout << wgt_id << ": height: " << height_val << endl;
00313 wgt->SetRelHeight( height_val );
00314 wgt->SetHeightAuto( false );
00315 }
00316 }
00317 }
00318 else
00319 {
00320 if( verbose_output ) cout << wgt_id << ": height not found, default to auto." << endl;
00321 wgt->SetHeightAuto( true );
00322 }
00323
00324
00325 if( !menu_file.GetParam( wgt_id + ".enabled", wgt_enabled ) )
00326 {
00327 if( verbose_output ) cout << wgt_id << ": enabled status unknown, default to on." << endl;
00328 wgt_enabled = true;
00329 }
00330 else
00331 {
00332 if( verbose_output ) cout << wgt_id << ": enabled: " << wgt_enabled << endl;
00333 }
00334 wgt->SetEnabled( wgt_enabled );
00335
00336
00337 if( !menu_file.GetParam( wgt_id + ".selected", wgt_selected ) )
00338 {
00339 if( verbose_output ) cout << wgt_id << ": selected status unknown, default to off." << endl;
00340 wgt_selected = false;
00341 }
00342 else
00343 {
00344 if( verbose_output ) cout << wgt_id << ": selected: " << wgt_selected << endl;
00345 }
00346 wgt->SetSelected( wgt_selected );
00347 if( wgt_selected )
00348 default_obj = cur_obj = n;
00349
00350
00351 if( !menu_file.GetParam( wgt_id + ".default", wgt_default ) )
00352 {
00353 if( verbose_output ) cout << wgt_id << ": default status unknown, default to off." << endl;
00354 wgt_default = false;
00355 }
00356 else
00357 {
00358 if( verbose_output ) cout << wgt_id << ": default: " << wgt_default << endl;
00359 }
00360 wgt->SetDefault( wgt_default );
00361
00362
00363 if( !menu_file.GetParam( wgt_id + ".cancel", wgt_cancel ) )
00364 {
00365 if( verbose_output ) cout << wgt_id << ": cancel status unknown, default to off." << endl;
00366 wgt_cancel = false;
00367 }
00368 else
00369 {
00370 if( verbose_output ) cout << wgt_id << ": cancel: " << wgt_cancel << endl;
00371 }
00372 wgt->SetCancel( wgt_cancel );
00373
00374
00375 if( !menu_file.GetParam( wgt_id + ".tip", wgt_tip ) )
00376 {
00377 if( verbose_output ) cout << wgt_id << ": tip not found, default to [empty]." << endl;
00378 wgt_tip = "";
00379 }
00380 else
00381 {
00382 wgt_tip = _(wgt_tip);
00383 if( verbose_output ) cout << wgt_id << ": tip: " << wgt_tip << endl;
00384 }
00385 wgt->SetTip( wgt_tip );
00386
00387 if( !menu_file.GetParam( wgt_id + ".values", value_source ) )
00388 {
00389 if( verbose_output ) cout << wgt_id << ": value source not found, default to manual." << endl;
00390 value_source = "manual";
00391 }
00392 else
00393 {
00394 if( verbose_output ) cout << wgt_id << ": value source: " << value_source << endl;
00395 }
00396
00397
00398 if( wgt_type == "button" )
00399 {
00400 btn = new Button( wgt );
00401 string action = "Main";
00402
00403 if( !menu_file.GetParam( wgt_id + ".action", action ) )
00404 {
00405 if( verbose_output ) cout << wgt_id << ": button action not found, default to Main." << endl;
00406 }
00407 else
00408 {
00409 if( verbose_output ) cout << wgt_id << ": button action: " << action << endl;
00410 }
00411 btn->SetAction( action );
00412
00413 page_objects.push_back( btn );
00414 }
00415 else if( wgt_type == "slider" )
00416 {
00417 sld = new Slider( wgt );
00418 float slider_val = -1.0;
00419
00420
00421 if( !menu_file.GetParam( wgt_id + ".setting", wgt_setting ) )
00422 {
00423 if( verbose_output ) cout << wgt_id << ": setting not found. This slider will not affect anything." << endl;
00424 }
00425 else
00426 {
00427 if( !settings.Get( wgt_setting, slider_val ) )
00428 {
00429 if( verbose_output ) cout << wgt_id << ": setting " << wgt_setting << " unknown. This slider will not affect anything." << endl;
00430 }
00431 else
00432 {
00433 if( verbose_output ) cout << wgt_id << ": slider hooked to " << wgt_setting << ", got value: " << slider_val << endl;
00434 }
00435 }
00436 sld->SetSetting( wgt_setting );
00437
00438 size_t pos = wgt_setting.find( ".", 0 );
00439 string cat = wgt_setting.substr( 0, pos );
00440 wgt_setting.erase( 0, pos + 1 );
00441 string name = wgt_setting;
00442 OPTION<float> option = settings.GetFloatOption( cat, name );
00443
00444
00445 if( value_source == "options" )
00446 {
00447 sld->SetText( _(option.GetTitle()) );
00448 sld->SetTip( _(option.GetDesc()) );
00449 if( slider_val == -1.0 )
00450 {
00451 sld->SetValue( option.GetDefaultValue() );
00452 sld->SetDefaultValue( option.GetDefaultValue() );
00453 }
00454 else
00455 {
00456 sld->SetValue( slider_val );
00457 sld->SetDefaultValue( slider_val );
00458 }
00459 }
00460 else if( value_source == "manual" )
00461 {
00462 if( !menu_file.GetParam( wgt_id + ".sliderval", slider_val ) )
00463 {
00464
00465 if( slider_val == -1.0 ) slider_val = 0.0;
00466 }
00467 else
00468 {
00469 if( verbose_output ) cout << wgt_id << ": slider value: " << slider_val << endl;
00470 }
00471 sld->SetValue( slider_val );
00472 sld->SetDefaultValue( slider_val );
00473 }
00474
00475 page_objects.push_back( sld );
00476 }
00477 else if( wgt_type == "toggle" )
00478 {
00479 tgl = new Toggle( wgt );
00480 bool tog = false;
00481 bool found_val = false;
00482 string tog_true, tog_false;
00483 float tog_spacing = 0.3;
00484
00485
00486 if( !menu_file.GetParam( wgt_id + ".setting", wgt_setting ) )
00487 {
00488 if( verbose_output ) cout << wgt_id << ": setting not found. This toggle will not affect anything." << endl;
00489 }
00490 else
00491 {
00492 if( !settings.Get( wgt_setting, tog ) )
00493 {
00494 if( verbose_output ) cout << wgt_id << ": setting unknown. This toggle will not affect anything." << endl;
00495 }
00496 else
00497 {
00498 if( verbose_output ) cout << wgt_id << ": toggle hooked to " << wgt_setting << ", got value: " << tog << endl;
00499 found_val = true;
00500 }
00501 }
00502 tgl->SetSetting( wgt_setting );
00503
00504 size_t pos = wgt_setting.find( ".", 0 );
00505 string cat = wgt_setting.substr( 0, pos );
00506 wgt_setting.erase( 0, pos + 1 );
00507 string name = wgt_setting;
00508 OPTION<bool> option = settings.GetBoolOption( cat, name );
00509 if( value_source == "options" )
00510 {
00511 tgl->SetText( _(option.GetTitle()) );
00512 tgl->SetTip( _(option.GetDesc()) );
00513 tgl->SetTrueText( _(option.GetTrueValue()) );
00514 tgl->SetFalseText( _(option.GetFalseValue()) );
00515 tgl->SetValue( tog );
00516 tgl->SetDefaultValue( tog );
00517 }
00518 else if( value_source == "manual" )
00519 {
00520 if( !menu_file.GetParam( wgt_id + ".toggleval", tog ) )
00521 {
00522
00523 }
00524 else
00525 {
00526 if( verbose_output ) cout << wgt_id << ": toggle value: " << tog << endl;
00527 }
00528 tgl->SetValue( tog );
00529 tgl->SetDefaultValue( tog );
00530
00531
00532 if( !menu_file.GetParam( wgt_id + ".true", tog_true ) )
00533 {
00534 if( verbose_output ) cout << wgt_id << ": toggle true text not found, default: On" << endl;
00535 tog_true = "On";
00536 }
00537 else
00538 {
00539 if( verbose_output ) cout << wgt_id << ": toggle true text: " << tog_true << endl;
00540 }
00541 tgl->SetTrueText( tog_true );
00542 if( !menu_file.GetParam( wgt_id + ".false", tog_false ) )
00543 {
00544 if( verbose_output ) cout << wgt_id << ": toggle false text not found, default: Off" << endl;
00545 tog_false = "Off";
00546 }
00547 else
00548 {
00549 if( verbose_output ) cout << wgt_id << ": toggle false text: " << tog_false << endl;
00550 }
00551 tgl->SetFalseText( tog_false );
00552 }
00553
00554
00555 if( !menu_file.GetParam( wgt_id + ".spacing", tog_spacing ) )
00556 {
00557 if( verbose_output ) cout << wgt_id << ": spacing not found, using default 0.3." << endl;
00558 tog_spacing = 0.3;
00559 }
00560 else
00561 {
00562 if( verbose_output ) cout << wgt_id << ": toggle spacing: " << tog_spacing << endl;
00563 }
00564 tgl->SetSpacing( tog_spacing );
00565
00566 page_objects.push_back( tgl );
00567 }
00568 else if( wgt_type == "floatwheel" )
00569 {
00570 fwhl = new Wheel<float>( wgt );
00571 vector<string> whl_list;
00572 vector<float> val_list;
00573 float whl_val_c = 0.0, whl_val = 0.0, whl_spacing = 0.3;
00574 int whl_opts;
00575
00576
00577 if( !menu_file.GetParam( wgt_id + ".setting", wgt_setting ) )
00578 {
00579 if( verbose_output ) cout << wgt_id << ": setting not found. This wheel will not affect anything." << endl;
00580 }
00581 else
00582 {
00583 if( !settings.Get( wgt_setting, whl_val ) )
00584 {
00585 if( verbose_output ) cout << wgt_id << ": setting unknown. This wheel will not affect anything." << endl;
00586 }
00587 else
00588 {
00589 if( verbose_output ) cout << wgt_id << ": wheel hooked to " << wgt_setting << ", got value: " << whl_val << endl;
00590 }
00591 }
00592 fwhl->SetSetting( wgt_setting );
00593
00594 size_t pos = wgt_setting.find( ".", 0 );
00595 string cat = wgt_setting.substr( 0, pos );
00596 wgt_setting.erase( 0, pos + 1 );
00597 string name = wgt_setting;
00598 OPTION<float> option = settings.GetFloatOption( cat, name );
00599 if( value_source == "options" )
00600 {
00601 fwhl->SetText( _(option.GetTitle()) );
00602 fwhl->SetTip( _(option.GetDesc()) );
00603 fwhl->SetOptionList( option.GetOptionList() );
00604 fwhl->SetValueList( option.GetValueList() );
00605 }
00606 else if( value_source == "manual" )
00607 {
00608
00609 if( !menu_file.GetParam( wgt_id + ".opts", whl_opts ) )
00610 {
00611 if( verbose_output ) cout << wgt_id << ": unknown number of wheel options." << endl;
00612 }
00613 else
00614 {
00615 if( verbose_output ) cout << wgt_id << ": reading " << whl_opts << " wheel options." << endl;
00616 for( int i = 0; i < whl_opts; i++ )
00617 {
00618 char optx[10];
00619 char valx[10];
00620 string stmp;
00621 float ftmp;
00622 sprintf( optx, ".opt%02d", i );
00623 sprintf( valx, ".val%02d", i );
00624 if( !menu_file.GetParam( wgt_id + optx, stmp ) )
00625 {
00626 if( verbose_output ) cout << wgt_id << ": option number " << i << " not found, aborting." << endl;
00627 break;
00628 }
00629 else
00630 {
00631 if( !menu_file.GetParam( wgt_id + valx, ftmp ) )
00632 {
00633 if( verbose_output ) cout << wgt_id << ": value number " << i << " not found, using 0.0." << endl;
00634 ftmp = 0.0;
00635 }
00636 else
00637 {
00638 if( verbose_output ) cout << wgt_id << ": float wheel option " << stmp << " (" << i << ") found, value: " << ftmp << endl;
00639 }
00640 whl_list.push_back( stmp );
00641 val_list.push_back( ftmp );
00642 }
00643 }
00644 }
00645 fwhl->SetOptionList( whl_list );
00646 fwhl->SetValueList( val_list );
00647 }
00648
00649 if( !menu_file.GetParam( wgt_id + ".wheelval", whl_val_c ) )
00650 {
00651
00652 whl_val_c = whl_val;
00653 }
00654 else
00655 {
00656 if( verbose_output ) cout << wgt_id << ": wheel value: " << whl_val_c << endl;
00657 }
00658 fwhl->SetValue( whl_val );
00659 fwhl->SetDefaultValue( whl_val );
00660
00661
00662 if( !menu_file.GetParam( wgt_id + ".spacing", whl_spacing ) )
00663 {
00664 if( verbose_output ) cout << wgt_id << ": spacing not found, using default 0.3." << endl;
00665 whl_spacing = 0.3;
00666 }
00667 else
00668 {
00669 if( verbose_output ) cout << wgt_id << ": wheel spacing: " << whl_spacing << endl;
00670 }
00671 fwhl->SetSpacing( whl_spacing );
00672
00673 page_objects.push_back( fwhl );
00674 }
00675 else if( wgt_type == "stringwheel" )
00676 {
00677 swhl = new Wheel<string>( wgt );
00678 vector<string> whl_list;
00679 vector<string> val_list;
00680 string whl_val = "";
00681 float whl_spacing;
00682 int whl_opts;
00683
00684
00685 if( !menu_file.GetParam( wgt_id + ".setting", wgt_setting ) )
00686 {
00687 if( verbose_output ) cout << wgt_id << ": setting not found. This wheel will not affect anything." << endl;
00688 }
00689 else
00690 {
00691 if( !settings.Get( wgt_setting, whl_val ) )
00692 {
00693 if( verbose_output ) cout << wgt_id << ": setting unknown. This wheel will not affect anything." << endl;
00694 }
00695 else
00696 {
00697 if( verbose_output ) cout << wgt_id << ": wheel hooked to " << wgt_setting << ", got value: " << whl_val << endl;
00698 }
00699 }
00700 swhl->SetSetting( wgt_setting );
00701
00702 size_t pos = wgt_setting.find( ".", 0 );
00703 string cat = wgt_setting.substr( 0, pos );
00704 wgt_setting.erase( 0, pos + 1 );
00705 string name = wgt_setting;
00706 OPTION<string> option = settings.GetStringOption( cat, name );
00707 if( value_source == "options" )
00708 {
00709 swhl->SetText( _(option.GetTitle()) );
00710 swhl->SetTip( _(option.GetDesc()) );
00711 swhl->SetOptionList( option.GetOptionList() );
00712 swhl->SetValueList( option.GetValueList() );
00713 }
00714 else if( value_source == "manual" )
00715 {
00716
00717 if( !menu_file.GetParam( wgt_id + ".opts", whl_opts ) )
00718 {
00719 if( verbose_output ) cout << wgt_id << ": unknown number of wheel options." << endl;
00720 }
00721 else
00722 {
00723 if( verbose_output ) cout << wgt_id << ": reading " << whl_opts << " wheel options." << endl;
00724 for( int i = 0; i < whl_opts; i++ )
00725 {
00726 char optx[10];
00727 char valx[10];
00728 string stmp;
00729 string ttmp;
00730 sprintf( optx, ".opt%02d", i );
00731 sprintf( valx, ".val%02d", i );
00732 if( !menu_file.GetParam( wgt_id + optx, stmp ) )
00733 {
00734 if( verbose_output ) cout << wgt_id << ": option number " << i << " not found, aborting." << endl;
00735 break;
00736 }
00737 else
00738 {
00739 if( !menu_file.GetParam( wgt_id + valx, ttmp ) )
00740 {
00741 if( verbose_output ) cout << wgt_id << ": value number " << i << " not found, using [empty]." << endl;
00742 ttmp = "";
00743 }
00744 else
00745 {
00746 if( verbose_output ) cout << wgt_id << ": string wheel option " << stmp << " (" << i << ") found, value: " << ttmp << endl;
00747 }
00748 whl_list.push_back( stmp );
00749 val_list.push_back( ttmp );
00750 }
00751 }
00752 }
00753 swhl->SetOptionList( whl_list );
00754 swhl->SetValueList( val_list );
00755 }
00756
00757 if( !menu_file.GetParam( wgt_id + ".wheelval", whl_val ) )
00758 {
00759
00760 }
00761 else
00762 {
00763 if( verbose_output ) cout << wgt_id << ": wheel value: " << whl_val << endl;
00764 }
00765 swhl->SetValue( whl_val );
00766 swhl->SetDefaultValue( whl_val );
00767
00768
00769 if( !menu_file.GetParam( wgt_id + ".hook", wgt_hook ) )
00770 {
00771 if( verbose_output ) cout << wgt_id << ": wheel hook not found. no hook." << endl;
00772 }
00773 else
00774 {
00775 if( verbose_output ) cout << wgt_id << ": wheel hooked to widget: " << wgt_hook << endl;
00776 }
00777 swhl->SetHook( wgt_hook );
00778
00779
00780 if( !menu_file.GetParam( wgt_id + ".spacing", whl_spacing ) )
00781 {
00782 if( verbose_output ) cout << wgt_id << ": spacing not found, using default 0.3." << endl;
00783 whl_spacing = 0.3;
00784 }
00785 else
00786 {
00787 if( verbose_output ) cout << wgt_id << ": wheel spacing: " << whl_spacing << endl;
00788 }
00789 swhl->SetSpacing( whl_spacing );
00790
00791 page_objects.push_back( swhl );
00792 }
00793 else if( wgt_type == "intwheel" )
00794 {
00795 iwhl = new Wheel<int>( wgt );
00796 vector<string> whl_list;
00797 vector<int> val_list;
00798 int whl_val = 0;
00799 float whl_spacing;
00800 int whl_opts;
00801
00802
00803 if( !menu_file.GetParam( wgt_id + ".setting", wgt_setting ) )
00804 {
00805 if( verbose_output ) cout << wgt_id << ": setting not found. This wheel will not affect anything." << endl;
00806 }
00807 else
00808 {
00809 if( !settings.Get( wgt_setting, whl_val ) )
00810 {
00811 if( verbose_output ) cout << wgt_id << ": setting unknown. This wheel will not affect anything." << endl;
00812 }
00813 else
00814 {
00815 if( verbose_output ) cout << wgt_id << ": wheel hooked to " << wgt_setting << ", got value: " << whl_val << endl;
00816 }
00817 }
00818 iwhl->SetSetting( wgt_setting );
00819
00820 size_t pos = wgt_setting.find( ".", 0 );
00821 string cat = wgt_setting.substr( 0, pos );
00822 wgt_setting.erase( 0, pos + 1 );
00823 string name = wgt_setting;
00824 OPTION<int> option = settings.GetIntOption( cat, name );
00825 if( value_source == "options" )
00826 {
00827 iwhl->SetText( _(option.GetTitle()) );
00828 iwhl->SetTip( _(option.GetDesc()) );
00829 iwhl->SetOptionList( option.GetOptionList() );
00830 iwhl->SetValueList( option.GetValueList() );
00831 }
00832 else if( value_source == "manual" )
00833 {
00834
00835 if( !menu_file.GetParam( wgt_id + ".opts", whl_opts ) )
00836 {
00837 if( verbose_output ) cout << wgt_id << ": unknown number of wheel options." << endl;
00838 }
00839 else
00840 {
00841 if( verbose_output ) cout << wgt_id << ": reading " << whl_opts << " wheel options." << endl;
00842 for( int i = 0; i < whl_opts; i++ )
00843 {
00844 char optx[10];
00845 char valx[10];
00846 string stmp;
00847 int ttmp;
00848 sprintf( optx, ".opt%02d", i );
00849 sprintf( valx, ".val%02d", i );
00850 if( !menu_file.GetParam( wgt_id + optx, stmp ) )
00851 {
00852 if( verbose_output ) cout << wgt_id << ": option number " << i << " not found, aborting." << endl;
00853 break;
00854 }
00855 else
00856 {
00857 if( !menu_file.GetParam( wgt_id + valx, ttmp ) )
00858 {
00859 if( verbose_output ) cout << wgt_id << ": value number " << i << " not found, using 0." << endl;
00860 ttmp = 0;
00861 }
00862 else
00863 {
00864 if( verbose_output ) cout << wgt_id << ": int wheel option " << stmp << " (" << i << ") found, value: " << ttmp << endl;
00865 }
00866 whl_list.push_back( stmp );
00867 val_list.push_back( ttmp );
00868 }
00869 }
00870 }
00871 iwhl->SetOptionList( whl_list );
00872 iwhl->SetValueList( val_list );
00873 }
00874
00875 if( !menu_file.GetParam( wgt_id + ".wheelval", whl_val ) )
00876 {
00877
00878 }
00879 else
00880 {
00881 if( verbose_output ) cout << wgt_id << ": wheel value: " << whl_val << endl;
00882 }
00883 iwhl->SetValue( whl_val );
00884 iwhl->SetDefaultValue( whl_val );
00885
00886 bool whl_saved;
00887 if( !menu_file.GetParam( wgt_id + ".saved", whl_saved ) )
00888 {
00889
00890 whl_saved = true;
00891 }
00892 else
00893 {
00894 if( verbose_output ) cout << wgt_id << ": wheel saved: " << whl_saved << endl;
00895 }
00896 iwhl->SetSaved( whl_saved );
00897
00898
00899 if( !menu_file.GetParam( wgt_id + ".hook", wgt_hook ) )
00900 {
00901 if( verbose_output ) cout << wgt_id << ": wheel hook not found. no hook." << endl;
00902 }
00903 else
00904 {
00905 if( verbose_output ) cout << wgt_id << ": wheel hooked to widget: " << wgt_hook << endl;
00906 }
00907 iwhl->SetHook( wgt_hook );
00908
00909
00910 if( !menu_file.GetParam( wgt_id + ".spacing", whl_spacing ) )
00911 {
00912 if( verbose_output ) cout << wgt_id << ": spacing not found, using default 0.3." << endl;
00913 whl_spacing = 0.3;
00914 }
00915 else
00916 {
00917 if( verbose_output ) cout << wgt_id << ": wheel spacing: " << whl_spacing << endl;
00918 }
00919 iwhl->SetSpacing( whl_spacing );
00920
00921 page_objects.push_back( iwhl );
00922 }
00923 else if( wgt_type == "intintwheel" )
00924 {
00925 iiwhl = new Wheel2<int, int>( wgt );
00926 string whl_setting_1, whl_setting_2;
00927 vector<string> whl_list;
00928 vector<int> val_list_1;
00929 vector<int> val_list_2;
00930 int whl_val_1 = 0;
00931 int whl_val_2 = 0;
00932 float whl_spacing;
00933 int whl_opts;
00934
00935
00936 if( !menu_file.GetParam( wgt_id + ".setting1", whl_setting_1 ) )
00937 {
00938 if( verbose_output ) cout << wgt_id << ": setting1 not found. This wheel will not affect anything." << endl;
00939 }
00940 else
00941 {
00942 if( !settings.Get( whl_setting_1, whl_val_1 ) )
00943 {
00944 if( verbose_output ) cout << wgt_id << ": setting1 unknown. This wheel will not affect anything." << endl;
00945 }
00946 else
00947 {
00948 if( verbose_output ) cout << wgt_id << ": wheel setting1 hooked to " << whl_setting_1 << ", got value: " << whl_val_1 << endl;
00949 }
00950 }
00951 iiwhl->SetSetting1( whl_setting_1 );
00952
00953
00954 if( !menu_file.GetParam( wgt_id + ".setting2", whl_setting_2 ) )
00955 {
00956 if( verbose_output ) cout << wgt_id << ": setting2 not found. This wheel will not affect anything." << endl;
00957 }
00958 else
00959 {
00960 if( !settings.Get( whl_setting_2, whl_val_2 ) )
00961 {
00962 if( verbose_output ) cout << wgt_id << ": setting2 unknown. This wheel will not affect anything." << endl;
00963 }
00964 else
00965 {
00966 if( verbose_output ) cout << wgt_id << ": wheel setting2 hooked to " << whl_setting_2 << ", got value: " << whl_val_2 << endl;
00967 }
00968 }
00969 iiwhl->SetSetting2( whl_setting_2 );
00970
00971 size_t pos = whl_setting_1.find( ".", 0 );
00972 string cat = whl_setting_1.substr( 0, pos );
00973 whl_setting_1.erase( 0, pos + 1 );
00974 string name = whl_setting_1;
00975 OPTION<int> option_1 = settings.GetIntOption( cat, name );
00976 pos = whl_setting_2.find( ".", 0 );
00977 cat = whl_setting_2.substr( 0, pos );
00978 whl_setting_2.erase( 0, pos + 1 );
00979 name = whl_setting_2;
00980 OPTION<int> option_2 = settings.GetIntOption( cat, name );
00981 if( value_source == "options" )
00982 {
00983 iiwhl->SetText( _(option_1.GetTitle()) );
00984 iiwhl->SetTip( _(option_1.GetDesc()) );
00985 iiwhl->SetOptionList( option_1.GetOptionList() );
00986 iiwhl->SetValueList1( option_1.GetValueList() );
00987 iiwhl->SetValueList2( option_2.GetValueList() );
00988 }
00989 else if( value_source == "manual" )
00990 {
00991
00992 if( !menu_file.GetParam( wgt_id + ".opts", whl_opts ) )
00993 {
00994 if( verbose_output ) cout << wgt_id << ": unknown number of wheel options." << endl;
00995 }
00996 else
00997 {
00998 if( verbose_output ) cout << wgt_id << ": reading " << whl_opts << " wheel options." << endl;
00999 for( int i = 0; i < whl_opts; i++ )
01000 {
01001 char optx[10];
01002 char valx[10];
01003 string stmp;
01004 int ttmp1, ttmp2;
01005 sprintf( optx, ".opt%02d", i );
01006 sprintf( valx, ".val%02d", i );
01007 if( !menu_file.GetParam( wgt_id + optx, stmp ) )
01008 {
01009 <