- Timestamp:
- 09/27/2008 03:42:22 PM (4 years ago)
- Location:
- trunk/src
- Files:
-
- 2 added
- 2 deleted
- 4 edited
-
MainFrame.cpp (modified) (13 diffs)
-
MainFrame.h (modified) (3 diffs)
-
Makefile.am (modified) (2 diffs)
-
SettingsDialog.cpp (deleted)
-
SettingsDialog.h (deleted)
-
configuration.cpp (modified) (1 diff)
-
settings_dialog.cpp (added)
-
settings_dialog.h (added)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/MainFrame.cpp
r158 r163 32 32 #include "ObjectsID.h" 33 33 #include "HighScoreDialog.h" 34 #include "SettingsDialog.h"35 34 #include "dice_theme_dialog.h" 36 35 #include "About.h" 37 36 #include "UtilityFunctions.h" 38 37 #include "configuration.h" 38 #include "settings_dialog.h" 39 39 #include <iostream> 40 40 #include <sstream> … … 79 79 wxRenameFile(home_path+wxT("/.OpenYahtzee"),home_path+wxT("/.openyahtzee"),false); 80 80 } 81 configuration::Configuration config("/home/guy/.openyahtzee.new"); 82 config.save(); 81 82 83 std::string config_file; 84 config_file = (home_path.mb_str()); 85 #ifndef PORTABLE 86 config_file += "/.openyahtzee.new"; 87 #else 88 config_file += "/openyahtzee.dat"; 89 #endif 90 91 m_config = new configuration::Configuration(config_file); 92 83 93 m_settingsdb = new SettingsDB(); //Get the settings database connection 84 94 m_highscoredb = new HighScoreTableDB(); … … 169 179 wxFlexGridSizer *diceSizer; 170 180 171 if (m_ settings.horizontal_layout) {181 if (m_config->get("horizontal-layout")=="True") { 172 182 topSizer = new wxBoxSizer( wxVERTICAL ); 173 183 sectionsSizer = new wxBoxSizer( wxHORIZONTAL ); … … 265 275 266 276 //BEGIN layout for the dice section of the score board 267 if (m_ settings.horizontal_layout) {277 if (m_config->get("horizontal-layout")=="True") { 268 278 diceSizer->Add(new wxDynamicBitmap(panel, ID_DICE1, 269 279 m_dice_graphics.GetDice(1)), 0, wxALL, DICE_SPACE); … … 529 539 void MainFrame::OnSettings( wxCommandEvent& event) 530 540 { 531 SettingsDialog *dialog = new SettingsDialog(this,wxID_ANY); 532 SettingsDialogData data; 533 std::ostringstream sstr; 534 535 data.highscoresize = m_highscoredb->GetSize(); 536 537 data.animate = (m_settingsdb->GetKey("animate")=="Yes")?true:false; 538 data.subtotal = (m_settingsdb->GetKey("calculatesubtotal")=="Yes")?true:false; 539 data.score_hints = m_settings.score_hints; 540 data.horizontal = (m_settingsdb->GetKey("horizontallayout")=="Yes")?true:false; 541 542 dialog->SetData(data); 543 544 if(dialog->ShowModal()!=wxID_OK) 545 return; 546 547 data = dialog->GetData(); 548 549 if(data.reset) 550 m_highscoredb->SetSize(0); 551 552 sstr<<data.highscoresize<<std::flush; 553 m_settingsdb->SetKey("highscoresize",sstr.str()); 554 555 m_highscoredb->SetSize(data.highscoresize); 556 557 if (data.animate){ 558 m_settingsdb->SetKey("animate","Yes"); 559 m_settings.animate = true; 560 } else { 561 m_settingsdb->SetKey("animate","No"); 562 m_settings.animate = false; 563 } 564 565 if (data.subtotal){ 566 m_settingsdb->SetKey("calculatesubtotal","Yes"); 567 m_settings.calculate_subtotal = true; 568 } else { 569 m_settingsdb->SetKey("calculatesubtotal","No"); 570 m_settings.calculate_subtotal = false; 571 } 541 settings_dialog::SettingsDialog* settings_dialog = new settings_dialog::SettingsDialog(this, m_config); 542 543 if (settings_dialog->ShowModal()!=wxID_OK) { 544 return; 545 } 546 572 547 ((wxTextCtrl*) FindWindow(ID_UPPERSECTIONTOTAL)) -> SetValue(wxT("")); 573 548 ((wxTextCtrl*) FindWindow(ID_LOWERTOTAL)) -> SetValue(wxT("")); 574 549 CalculateSubTotal(); 575 550 576 if (data.score_hints){ 577 m_settingsdb->SetKey("score_hints","Yes"); 578 m_settings.score_hints = true; 579 } else { 580 m_settingsdb->SetKey("score_hints","No"); 581 m_settings.score_hints = false; 582 } 583 584 if (data.horizontal){ 585 m_settingsdb->SetKey("horizontallayout","Yes"); 586 m_settings.horizontal_layout = true; 587 Relayout(); 588 } else { 589 m_settingsdb->SetKey("horizontallayout","No"); 590 m_settings.horizontal_layout = false; 591 Relayout(); 592 } 551 Relayout(); 552 553 delete settings_dialog; 593 554 } 594 555 … … 634 595 dice[4]=m_score_dice.GetDice(5); 635 596 //roll the dice... 636 if (m_ settings.animate) {597 if (m_config->get("dice-animation")=="True") { 637 598 int dice_throws[5] = {0,0,0,0,0}; 638 599 for (int i=0; i<5; i++) { //set the number of rolls for each dice … … 1095 1056 void MainFrame::CalculateSubTotal() 1096 1057 { 1097 if ( !m_settings.calculate_subtotal)1058 if (m_config->get("calculate-subtotal")=="False") 1098 1059 return; 1099 1060 long upperscore = 0; … … 1148 1109 } 1149 1110 1150 if (m_settingsdb->GetKey("animate") == "Yes") {1151 m_settings.animate = true;1152 } else if (m_settingsdb->GetKey("animate") == "No") {1153 m_settings.animate = false;1154 } else {1155 m_settingsdb->SetKey("animate", "Yes");1156 m_settings.animate = true;1157 }1158 1159 if (m_settingsdb->GetKey("calculatesubtotal") == "Yes") {1160 m_settings.calculate_subtotal = true;1161 } else if (m_settingsdb->GetKey("calculatesubtotal") == "No") {1162 m_settings.calculate_subtotal = false;1163 } else {1164 m_settingsdb->SetKey("calculatesubtotal", "Yes");1165 m_settings.calculate_subtotal = true;1166 }1167 1168 if (m_settingsdb->GetKey("horizontallayout") == "Yes") {1169 m_settings.horizontal_layout = true;1170 } else if (m_settingsdb->GetKey("horizontallayout") == "No") {1171 m_settings.horizontal_layout = false;1172 } else {1173 m_settingsdb->SetKey("horizontallayout", "No");1174 m_settings.horizontal_layout = true;1175 }1176 1177 if (m_settingsdb->GetKey("score_hints") == "Yes") {1178 m_settings.score_hints = true;1179 } else if (m_settingsdb->GetKey("score_hints") == "No") {1180 m_settings.score_hints = false;1181 } else {1182 m_settingsdb->SetKey("score_hints", "Yes");1183 m_settings.score_hints = true;1184 }1185 1111 1186 1112 return 1; … … 1198 1124 sectionsSizer->Remove(uppersection); 1199 1125 1200 if (m_ settings.horizontal_layout) {1126 if (m_config->get("horizontal-layout")=="True") { 1201 1127 topSizer = new wxBoxSizer( wxVERTICAL ); 1202 1128 sectionsSizer = new wxBoxSizer( wxHORIZONTAL ); … … 1265 1191 //Change the roll button size if we need to 1266 1192 roll_button_enabled = FindWindow(ID_ROLL)->IsEnabled(); 1267 if (m_ settings.horizontal_layout) {1193 if (m_config->get("horizontal-layout")=="True") { 1268 1194 FindWindow(ID_ROLL)->Destroy(); 1269 1195 new wxButton(FindWindow(ID_PANEL), ID_ROLL, wxT("Roll!"),wxDefaultPosition,wxSize(64,64)); … … 1282 1208 1283 1209 //BEGIN layout for the dice section of the score board 1284 if (m_ settings.horizontal_layout) {1210 if (m_config->get("horizontal-layout")=="True") { 1285 1211 diceSizer->Add(FindWindow(ID_DICE1),0,wxALL,DICE_SPACE); 1286 1212 diceSizer->Add(FindWindow(ID_DICE2),0,wxALL,DICE_SPACE); … … 1346 1272 wxTextCtrl *text_control; 1347 1273 wxString out; 1348 if ( ! m_main_frame->m_settings.score_hints) {1274 if (m_main_frame->m_config->get("score-hints")=="False") { 1349 1275 event.Skip(); 1350 1276 return; … … 1427 1353 event.Skip(); //allow default proccesing 1428 1354 } 1355 1356 MainFrame::~MainFrame() { 1357 // free pointers 1358 delete m_config; 1359 delete m_settingsdb; 1360 delete m_highscoredb; 1361 delete m_evt_handler; 1362 } -
trunk/src/MainFrame.h
r137 r163 29 29 #include "ScoreDice.h" 30 30 #include "dice_graphics.h" 31 #include "configuration.h" 31 32 #ifndef MAINFRAME_INC 32 33 #define MAINFRAME_INC … … 44 45 // Constructor 45 46 MainFrame(const wxString& title, const wxSize& size, long style); 47 ~MainFrame(); 46 48 47 49 // Event handlers … … 75 77 ScoreDice m_score_dice; 76 78 77 struct { 78 bool animate; 79 bool calculate_subtotal; 80 bool horizontal_layout; 81 bool score_hints; 82 } m_settings; 79 configuration::Configuration *m_config; 83 80 84 81 private: -
trunk/src/Makefile.am
r157 r163 14 14 openyahtzee.cpp \ 15 15 SettingsDB.cpp \ 16 SettingsDialog.cpp \ 16 settings_dialog.cpp \ 17 settings_dialog.h \ 17 18 ScoreDice.cpp \ 18 19 UtilityFunctions.cpp \ … … 56 57 ObjectsID.h \ 57 58 SettingsDB.h \ 58 SettingsDialog.h \59 59 ScoreDice.h \ 60 60 UtilityFunctions.h \ -
trunk/src/configuration.cpp
r161 r163 188 188 m_settings["dice-animation"] = "True"; 189 189 m_settings["calculate-subtotal"] = "True"; 190 m_settings["calculate-subtotal"] = "True";191 190 m_settings["horizontal-layout"] = "True"; 192 191 m_settings["score-hints"] = "True";
Note: See TracChangeset
for help on using the changeset viewer.
