77#include < QObject>
88#include < QMessageBox>
99#include < QFile>
10+ #include < QDebug>
1011
1112#include " ../util/path_helpers.h"
1213#include " FightCategoryParser.h"
@@ -24,14 +25,14 @@ FightCategoryMgr::FightCategoryMgr()
2425 : m_Categories()
2526// ---------------------------------------------------------
2627{
27- load_categories ();
28+ LoadCategories ();
2829}
2930
3031// ---------------------------------------------------------
3132FightCategoryMgr::~FightCategoryMgr ()
3233// ---------------------------------------------------------
3334{
34- save_categories ();
35+ SaveCategories ();
3536}
3637
3738// ---------------------------------------------------------
@@ -145,7 +146,7 @@ void FightCategoryMgr::RemoveCategory(QString const& name)
145146}
146147
147148// ---------------------------------------------------------
148- void FightCategoryMgr::load_categories ()
149+ void FightCategoryMgr::LoadCategories ()
149150// ---------------------------------------------------------
150151{
151152 auto configFile {fm::GetSettingsFilePath (str_configFileName)};
@@ -155,22 +156,26 @@ void FightCategoryMgr::load_categories()
155156 {
156157 if (QFile::exists (configFile))
157158 {
159+ qInfo () << " Reading categories from config:" << configFile;
158160 m_Categories = FightCategoryParser::ParseIniFile (configFile);
159161 }
160162 else
161163 {
162164 if (!QFile::exists (legacyFile))
163165 {
166+ qInfo () << " Loading default categories" ;
164167 load_default_categories ();
165168 }
166169 else
167170 {
171+ qInfo () << " Reading categories from legacy config:" << legacyFile;
168172 m_Categories = FightCategoryParser::ParseJsonFile (legacyFile);
169173 }
170174 }
171175 }
172176 catch (std::exception const & e)
173177 {
178+ qWarning () << " Error loading categories, restoring defaults" ;
174179 QMessageBox::critical (nullptr ,
175180 QString (QObject::tr (" Error" )),
176181 QString (QObject::tr (" Unable to load fight categories:\n %1\n\n Restoring defaults." ).arg (
@@ -181,9 +186,10 @@ void FightCategoryMgr::load_categories()
181186}
182187
183188// ---------------------------------------------------------
184- void FightCategoryMgr::save_categories ()
189+ void FightCategoryMgr::SaveCategories ()
185190// ---------------------------------------------------------
186191{
192+ qInfo () << " Saving categories to:" << str_configFileName;
187193 auto filePath {fm::GetSettingsFilePath (str_configFileName)};
188194 FightCategoryParser::ToIniFile (filePath, m_Categories);
189195}
@@ -240,74 +246,62 @@ void FightCategoryMgr::load_default_categories()
240246 m_Categories.clear ();
241247
242248 FightCategory t (" M" );
243- t.SetWeights (" -60;-66;-73;-81;-90;-100;+100 " );
249+ t.SetWeights (" -60kg;-66kg;-73kg;-81kg;-90kg;-100kg;+100kg " );
244250 t.SetRoundTime (4 * 60 );
245- t.SetGoldenScoreTime (3 * 60 );
246- AddCategory (t);
247-
248- t = FightCategory (" MU20" );
249- t.SetWeights (" -55;-60;-66;-73;-81;-90;-100;+100" );
250- t.SetRoundTime (4 * 60 );
251- t.SetGoldenScoreTime (2 * 60 );
251+ t.SetGoldenScoreTime (0 );
252252 AddCategory (t);
253253
254- t = FightCategory (" MU19 " );
255- t.SetWeights (" -55;-60;-66;-73;-81;-90;-100;+100 " );
254+ t = FightCategory (" MU21 " );
255+ t.SetWeights (" -60kg;-66kg;-73kg;-81kg;-90kg;-100kg;+100kg " );
256256 t.SetRoundTime (4 * 60 );
257- t.SetGoldenScoreTime (2 * 60 );
257+ t.SetGoldenScoreTime (0 );
258258 AddCategory (t);
259259
260- t = FightCategory (" MU17 " );
261- t.SetWeights (" -43;-46;-50;-55;-60;-66;-73;-81;-90;+90 " );
260+ t = FightCategory (" MU18 " );
261+ t.SetWeights (" -46kg;-50kg;-55kg;-60kg;-66kg;-73kg;-81kg;-90kg;+90kg " );
262262 t.SetRoundTime (4 * 60 );
263- t.SetGoldenScoreTime (2 * 60 );
263+ t.SetGoldenScoreTime (0 );
264264 AddCategory (t);
265265
266- t = FightCategory (" MU16 " );
267- t.SetWeights (" -40;-43;-46;-50;-55;-60;-66;-73;-81;+81 " );
268- t.SetRoundTime (4 * 60 );
269- t.SetGoldenScoreTime (2 * 60 );
266+ t = FightCategory (" MU15 " );
267+ t.SetWeights (" -34kg;-37kg;-40kg;-43kg;-46kg;-50kg;-55kg;-60kg;-66kg;+66kg " );
268+ t.SetRoundTime (3 * 60 );
269+ t.SetGoldenScoreTime (3 * 60 );
270270 AddCategory (t);
271271
272- t = FightCategory (" MU14 " );
273- t.SetWeights (" -31;-34;-37;-40;-43;-46;-50;-55;-60;+60 " );
272+ t = FightCategory (" MU13 " );
273+ t.SetWeights (" -28kg;-31kg;-34kg;-37kg;-40kg;-43kg;-46kg;-50kg;-55kg;+55kg " );
274274 t.SetRoundTime (3 * 60 );
275- t.SetGoldenScoreTime (90 );
275+ t.SetGoldenScoreTime (0 );
276276 AddCategory (t);
277277
278278 t = FightCategory (" F" );
279- t.SetWeights (" -48;-52;-57;-63;-70;-78;+78 " );
279+ t.SetWeights (" -48kg;-52kg;-57kg;-63kg;-70kg;-78kg;+78kg " );
280280 t.SetRoundTime (4 * 60 );
281- t.SetGoldenScoreTime (3 * 60 );
282- AddCategory (t);
283-
284- t = FightCategory (" FU20" );
285- t.SetWeights (" -44;-48;-52;-57;-63;-70;-78;+78" );
286- t.SetRoundTime (4 * 60 );
287- t.SetGoldenScoreTime (2 * 60 );
281+ t.SetGoldenScoreTime (0 );
288282 AddCategory (t);
289283
290- t = FightCategory (" FU19 " );
291- t.SetWeights (" -44;-48;-52;-57;-63;-70;-78;+78 " );
284+ t = FightCategory (" FU21 " );
285+ t.SetWeights (" -48kg;-52kg;-57kg;-63kg;-70kg;-78kg;+78kg " );
292286 t.SetRoundTime (4 * 60 );
293- t.SetGoldenScoreTime (2 * 60 );
287+ t.SetGoldenScoreTime (0 );
294288 AddCategory (t);
295289
296- t = FightCategory (" FU17 " );
297- t.SetWeights (" -40;-44;-48;-52;-57;-63;-70;-78;+78 " );
290+ t = FightCategory (" FU18 " );
291+ t.SetWeights (" -40kg;-44kg;-48kg;-52kg;-57kg;-63kg;-70kg;-78kg;+78kg " );
298292 t.SetRoundTime (4 * 60 );
299- t.SetGoldenScoreTime (2 * 60 );
293+ t.SetGoldenScoreTime (0 );
300294 AddCategory (t);
301295
302- t = FightCategory (" FU16 " );
303- t.SetWeights (" -40;-44;-48;-52;-57;-63;-70;+70 " );
304- t.SetRoundTime (4 * 60 );
305- t.SetGoldenScoreTime (2 * 60 );
296+ t = FightCategory (" FU15 " );
297+ t.SetWeights (" -33kg;-36kg;-40kg;-44kg;-48kg;-52kg;-57kg;-63kg;+63kg " );
298+ t.SetRoundTime (3 * 60 );
299+ t.SetGoldenScoreTime (3 * 60 );
306300 AddCategory (t);
307301
308- t = FightCategory (" FU14 " );
309- t.SetWeights (" -30;-33;-36;-40;-44;-48;-52;-57;-63;+63 " );
302+ t = FightCategory (" FU13 " );
303+ t.SetWeights (" -27kg;-30kg;-33kg;-36kg;-40kg;-44kg;-48kg;-52kg;-57kg;+57kg " );
310304 t.SetRoundTime (3 * 60 );
311- t.SetGoldenScoreTime (90 );
305+ t.SetGoldenScoreTime (0 );
312306 AddCategory (t);
313307}
0 commit comments