378
void Bridge::load(KConfig *cfg)
378
void Bridge::load(KConfigGroup *cfgGroup)
383
void Bridge::doLoad(KConfig *cfg)
383
void Bridge::doLoad(KConfigGroup *cfgGroup)
385
newSize(cfg->readEntry("width", width()), cfg->readEntry("height", height()));
386
setTopWallVisible(cfg->readEntry("topWallVisible", topWallVisible()));
387
setBotWallVisible(cfg->readEntry("botWallVisible", botWallVisible()));
388
setLeftWallVisible(cfg->readEntry("leftWallVisible", leftWallVisible()));
389
setRightWallVisible(cfg->readEntry("rightWallVisible", rightWallVisible()));
385
newSize(cfgGroup->readEntry("width", width()), cfgGroup->readEntry("height", height()));
386
setTopWallVisible(cfgGroup->readEntry("topWallVisible", topWallVisible()));
387
setBotWallVisible(cfgGroup->readEntry("botWallVisible", botWallVisible()));
388
setLeftWallVisible(cfgGroup->readEntry("leftWallVisible", leftWallVisible()));
389
setRightWallVisible(cfgGroup->readEntry("rightWallVisible", rightWallVisible()));
400
400
baseRightWallY = rightWall->y();
403
void Bridge::save(KConfig *cfg)
403
void Bridge::save(KConfigGroup *cfgGroup)
408
void Bridge::doSave(KConfig *cfg)
408
void Bridge::doSave(KConfigGroup *cfgGroup)
410
cfg->writeEntry("width", width());
411
cfg->writeEntry("height", height());
412
cfg->writeEntry("topWallVisible", topWallVisible());
413
cfg->writeEntry("botWallVisible", botWallVisible());
414
cfg->writeEntry("leftWallVisible", leftWallVisible());
415
cfg->writeEntry("rightWallVisible", rightWallVisible());
410
cfgGroup->writeEntry("width", width());
411
cfgGroup->writeEntry("height", height());
412
cfgGroup->writeEntry("topWallVisible", topWallVisible());
413
cfgGroup->writeEntry("botWallVisible", botWallVisible());
414
cfgGroup->writeEntry("leftWallVisible", leftWallVisible());
415
cfgGroup->writeEntry("rightWallVisible", rightWallVisible());
418
418
QList<QGraphicsItem *> Bridge::moveableItems() const
569
569
right->setGame(game);
572
void Windmill::save(KConfig *cfg)
572
void Windmill::save(KConfigGroup *cfgGroup)
574
cfg->writeEntry("speed", speed);
575
cfg->writeEntry("bottom", m_bottom);
574
cfgGroup->writeEntry("speed", speed);
575
cfgGroup->writeEntry("bottom", m_bottom);
580
void Windmill::load(KConfig *cfg)
580
void Windmill::load(KConfigGroup *cfgGroup)
582
setSpeed(cfg->readEntry("speed", -1));
582
setSpeed(cfgGroup->readEntry("speed", -1));
586
586
left->editModeChanged(false);
587
587
right->editModeChanged(false);
588
588
guard->editModeChanged(false);
590
setBottom(cfg->readEntry("bottom", true));
590
setBottom(cfgGroup->readEntry("bottom", true));
592
592
baseGuardMin = guard->getMin();
593
593
baseGuardMax = guard->getMax();
674
674
Bridge::resize(resizeFactor);
677
void Sign::load(KConfig *cfg)
677
void Sign::load(KConfigGroup *cfgGroup)
679
m_text = cfg->readEntry("Comment", m_text);
680
m_untranslatedText = cfg->readEntryUntranslated("Comment", m_untranslatedText);
679
m_text = cfgGroup->readEntry("Comment", m_text);
680
m_untranslatedText = cfgGroup->readEntryUntranslated("Comment", m_untranslatedText);
685
void Sign::save(KConfig *cfg)
685
void Sign::save(KConfigGroup *cfgGroup)
687
cfg->writeEntry("Comment", m_untranslatedText);
687
cfgGroup->writeEntry("Comment", m_untranslatedText);
692
692
void Sign::setText(const QString &text)
911
void KolfEllipse::load(KConfig *cfg)
911
void KolfEllipse::load(KConfigGroup *cfgGroup)
913
setChangeEnabled(cfg->readEntry("changeEnabled", changeEnabled()));
914
setChangeEvery(cfg->readEntry("changeEvery", changeEvery()));
913
setChangeEnabled(cfgGroup->readEntry("changeEnabled", changeEnabled()));
914
setChangeEvery(cfgGroup->readEntry("changeEvery", changeEvery()));
915
915
double newWidth = width(), newHeight = height();
916
newWidth = cfg->readEntry("width", newWidth);
917
newHeight = cfg->readEntry("height", newHeight);
916
newWidth = cfgGroup->readEntry("width", newWidth);
917
newHeight = cfgGroup->readEntry("height", newHeight);
918
918
newSize(newWidth, newHeight);
922
void KolfEllipse::save(KConfig *cfg)
922
void KolfEllipse::save(KConfigGroup *cfgGroup)
924
cfg->writeEntry("changeEvery", changeEvery());
925
cfg->writeEntry("changeEnabled", changeEnabled());
926
cfg->writeEntry("width", width());
927
cfg->writeEntry("height", height());
924
cfgGroup->writeEntry("changeEvery", changeEvery());
925
cfgGroup->writeEntry("changeEnabled", changeEnabled());
926
cfgGroup->writeEntry("width", width());
927
cfgGroup->writeEntry("height", height());
930
930
Config *KolfEllipse::config(QWidget *parent)
1330
1330
pixmap=game->renderer->renderSvg("cup", (int)rect().width(), (int)rect().height(), 0);
1333
void Cup::save(KConfig *cfg)
1333
void Cup::save(KConfigGroup *cfgGroup)
1335
cfg->writeEntry("dummykey", true);
1335
cfgGroup->writeEntry("dummykey", true);
1338
1338
void Cup::saveState(StateDB *db)
1590
1590
playSound("blackhole");
1593
void BlackHole::load(KConfig *cfg)
1593
void BlackHole::load(KConfigGroup *cfgGroup)
1595
QPoint exit = cfg->readEntry("exit", exit);
1595
QPoint exit = cfgGroup->readEntry("exit", exit);
1596
1596
exitItem->setPos(exit.x(), exit.y());
1597
exitDeg = cfg->readEntry("exitDeg", exitDeg);
1598
m_minSpeed = cfg->readEntry("minspeed", m_minSpeed);
1599
m_maxSpeed = cfg->readEntry("maxspeed", m_maxSpeed);
1597
exitDeg = cfgGroup->readEntry("exitDeg", exitDeg);
1598
m_minSpeed = cfgGroup->readEntry("minspeed", m_minSpeed);
1599
m_maxSpeed = cfgGroup->readEntry("maxspeed", m_maxSpeed);
1600
1600
exitItem->updateArrowAngle();
1601
1601
exitItem->updateArrowLength();
1637
1637
exitItem->setVisible(true);
1640
void BlackHole::save(KConfig *cfg)
1640
void BlackHole::save(KConfigGroup *cfgGroup)
1642
cfg->writeEntry("exit", QPointF(exitItem->x(), exitItem->y()));
1643
cfg->writeEntry("exitDeg", exitDeg);
1644
cfg->writeEntry("minspeed", m_minSpeed);
1645
cfg->writeEntry("maxspeed", m_maxSpeed);
1642
cfgGroup->writeEntry("exit", QPointF(exitItem->x(), exitItem->y()));
1643
cfgGroup->writeEntry("exitDeg", exitDeg);
1644
cfgGroup->writeEntry("minspeed", m_minSpeed);
1645
cfgGroup->writeEntry("maxspeed", m_maxSpeed);
1648
1648
HoleResult BlackHole::result(QPointF p, double s, bool * /*wasCenter*/)
2216
void Wall::load(KConfig *cfg)
2216
void Wall::load(KConfigGroup *cfgGroup)
2218
2218
QPoint start(startPoint());
2219
start = cfg->readEntry("startPoint", start);
2219
start = cfgGroup->readEntry("startPoint", start);
2220
2220
QPoint end(endPoint());
2221
end = cfg->readEntry("endPoint", end);
2221
end = cfgGroup->readEntry("endPoint", end);
2223
2223
setLine(start.x(), start.y(), end.x(), end.y());
2227
2227
endItem->setPos(end.x()-1, end.y()-1);
2230
void Wall::save(KConfig *cfg)
2230
void Wall::save(KConfigGroup *cfgGroup)
2232
cfg->writeEntry("startPoint", QPoint((int)startItem->x(), (int)startItem->y()));
2233
cfg->writeEntry("endPoint", QPoint((int)endItem->x(), (int)endItem->y()));
2232
cfgGroup->writeEntry("startPoint", QPoint((int)startItem->x(), (int)startItem->y()));
2233
cfgGroup->writeEntry("endPoint", QPoint((int)endItem->x(), (int)endItem->y()));
2236
2236
void Wall::doAdvance()
2597
2598
for (; scoreboardHoles < curHole; ++scoreboardHoles)
2599
cfg->setGroup(QString("%1-hole@-50,-50|0").arg(scoreboardHoles + 1));
2600
emit newHole(cfg->readEntry("par", 3));
2600
cfgGroup = new KConfigGroup(cfg->group(QString("%1-hole@-50,-50|0").arg(scoreboardHoles + 1)));
2601
emit newHole(cfgGroup->readEntry("par", 3));
2603
2604
// lets load all of the scores from saved game if there are any
3776
3777
for (; scoreboardHoles < curHole; ++scoreboardHoles)
3778
cfg->setGroup(QString("%1-hole@-50,-50|0").arg(scoreboardHoles + 1));
3779
emit newHole(cfg->readEntry("par", 3));
3779
cfgGroup = new KConfigGroup(cfg->group(QString("%1-hole@-50,-50|0").arg(scoreboardHoles + 1)));
3780
emit newHole(cfgGroup->readEntry("par", 3));
3782
3783
resetHoleScores();
3837
3838
// we do this here for the hell of it.
3838
3839
// there is no fake id, by the way,
3839
3840
// because it's old and when i added ids i forgot to change it.
3840
cfg->setGroup("0-course@-50,-50");
3841
holeInfo.setAuthor(cfg->readEntry("author", holeInfo.author()));
3842
holeInfo.setName(cfg->readEntry("Name", holeInfo.name()));
3843
holeInfo.setUntranslatedName(cfg->readEntryUntranslated("Name", holeInfo.untranslatedName()));
3841
cfgGroup = new KConfigGroup(cfg->group(QString("0-course@-50,-50")));
3842
holeInfo.setAuthor(cfgGroup->readEntry("author", holeInfo.author()));
3843
holeInfo.setName(cfgGroup->readEntry("Name", holeInfo.name()));
3844
holeInfo.setUntranslatedName(cfgGroup->readEntryUntranslated("Name", holeInfo.untranslatedName()));
3844
3845
emit titleChanged(holeInfo.name());
3846
cfg->setGroup(QString("%1-hole@-50,-50|0").arg(curHole));
3847
curPar = cfg->readEntry("par", 3);
3847
cfgGroup = new KConfigGroup(KSharedConfig::openConfig(filename), QString("%1-hole@-50,-50|0").arg(curHole));
3848
curPar = cfgGroup->readEntry("par", 3);
3848
3849
holeInfo.setPar(curPar);
3849
holeInfo.borderWallsChanged(cfg->readEntry("borderWalls", holeInfo.borderWalls()));
3850
holeInfo.setMaxStrokes(cfg->readEntry("maxstrokes", 10));
3851
bool hasFinalLoad = cfg->readEntry("hasFinalLoad", true);
3850
holeInfo.borderWallsChanged(cfgGroup->readEntry("borderWalls", holeInfo.borderWalls()));
3851
holeInfo.setMaxStrokes(cfgGroup->readEntry("maxstrokes", 10));
3852
bool hasFinalLoad = cfgGroup->readEntry("hasFinalLoad", true);
3853
3854
QStringList missingPlugins;
3854
3855
QStringList groups = cfg->groupList();
3859
3860
for (QStringList::Iterator it = groups.begin(); it != groups.end(); ++it)
3861
3862
// [<holeNum>-<name>@<x>,<y>|<id>]
3863
cfgGroup = new KConfigGroup(cfg->group(*it));
3864
3865
const int len = (*it).length();
3865
3866
const int dashIndex = (*it).indexOf("-");
3930
3931
// make things actually show
3931
3932
if (!hasFinalLoad)
3933
cfg->setGroup(makeGroup(id, curHole, sceneItem->name(), x, y));
3934
sceneItem->load(cfg);
3934
cfgGroup = new KConfigGroup(cfg->group(makeGroup(id, curHole, sceneItem->name(), x, y)));
3935
sceneItem->load(cfgGroup);
3937
3938
// we don't allow multiple items for the same thing in
4001
4002
qsceneItem = qtodo.constBegin();
4002
4003
for (citem = todo.constBegin(); citem != todo.constEnd(); ++citem)
4004
cfg->setGroup(makeGroup((*citem)->curId(), curHole, (*citem)->name(), (int)(*qsceneItem)->x(), (int)(*qsceneItem)->y()));
4005
(*citem)->load(cfg);
4005
cfgGroup = new KConfigGroup(cfg->group(makeGroup((*citem)->curId(), curHole, (*citem)->name(), (int)(*qsceneItem)->x(), (int)(*qsceneItem)->y())));
4006
(*citem)->load(cfgGroup);
4329
4330
citem->clean();
4331
cfg->setGroup(makeGroup(citem->curId(), curHole, citem->name(), (int)(*item)->x(), (int)(*item)->y()));
4332
cfgGroup = new KConfigGroup(cfg->group(makeGroup(citem->curId(), curHole, citem->name(), (int)(*item)->x(), (int)(*item)->y())));
4333
citem->save(cfgGroup);
4336
4337
// save where ball starts (whiteBall tells all)
4337
cfg->setGroup(QString("%1-ball@%2,%3").arg(curHole).arg((int)whiteBall->x()).arg((int)whiteBall->y()));
4338
cfg->writeEntry("dummykey", true);
4338
cfgGroup = new KConfigGroup(cfg->group(QString("%1-ball@%2,%3").arg(curHole).arg((int)whiteBall->x()).arg((int)whiteBall->y())));
4339
cfgGroup->writeEntry("dummykey", true);
4340
cfg->setGroup("0-course@-50,-50");
4341
cfg->writeEntry("author", holeInfo.author());
4342
cfg->writeEntry("Name", holeInfo.untranslatedName());
4341
cfgGroup = new KConfigGroup(cfg->group(QString("0-course@-50,-50")));
4342
cfgGroup->writeEntry("author", holeInfo.author());
4343
cfgGroup->writeEntry("Name", holeInfo.untranslatedName());
4344
4345
// save hole info
4345
cfg->setGroup(QString("%1-hole@-50,-50|0").arg(curHole));
4346
cfg->writeEntry("par", holeInfo.par());
4347
cfg->writeEntry("maxstrokes", holeInfo.maxStrokes());
4348
cfg->writeEntry("borderWalls", holeInfo.borderWalls());
4349
cfg->writeEntry("hasFinalLoad", hasFinalLoad);
4346
cfgGroup = new KConfigGroup(cfg->group(QString("%1-hole@-50,-50|0").arg(curHole)));
4347
cfgGroup->writeEntry("par", holeInfo.par());
4348
cfgGroup->writeEntry("maxstrokes", holeInfo.maxStrokes());
4349
cfgGroup->writeEntry("borderWalls", holeInfo.borderWalls());
4350
cfgGroup->writeEntry("hasFinalLoad", hasFinalLoad);
4517
4518
void KolfGame::courseInfo(CourseInfo &info, const QString& filename)
4519
KConfig cfg(filename);
4520
cfg.setGroup("0-course@-50,-50");
4521
info.author = cfg.readEntry("author", info.author);
4522
info.name = cfg.readEntry("Name", cfg.readEntry("name", info.name));
4523
info.untranslatedName = cfg.readEntryUntranslated("Name", cfg.readEntryUntranslated("name", info.name));
4520
KConfig config(filename);
4521
KConfigGroup configGroup (config.group(QString("0-course@-50,-50")));
4522
info.author = configGroup.readEntry("author", info.author);
4523
info.name = configGroup.readEntry("Name", configGroup.readEntry("name", info.name));
4524
info.untranslatedName = configGroup.readEntryUntranslated("Name", configGroup.readEntryUntranslated("name", info.name));
4525
4526
unsigned int hole = 1;
4526
4527
unsigned int par= 0;
4529
4530
QString group = QString("%1-hole@-50,-50|0").arg(hole);
4530
if (!cfg.hasGroup(group))
4531
if (!config.hasGroup(group))
4536
cfg.setGroup(group);
4537
par += cfg.readEntry("par", 3);
4537
configGroup = KConfigGroup(config.group(group));
4538
par += configGroup.readEntry("par", 3);
4546
4547
void KolfGame::scoresFromSaved(KConfig *config, PlayerList &players)
4548
config->setGroup("0 Saved Game");
4549
int numPlayers = config->readEntry("Players", 0);
4549
KConfigGroup *configGroup = new KConfigGroup(config->group(QString("0 Saved Game")));
4550
int numPlayers = configGroup->readEntry("Players", 0);
4550
4551
if (numPlayers <= 0)
4553
4554
for (int i = 1; i <= numPlayers; ++i)
4555
4556
// this is same as in kolf.cpp, but we use saved game values
4556
config->setGroup(QString::number(i));
4557
configGroup = new KConfigGroup(config->group(QString::number(i)));
4557
4558
players.append(Player());
4558
players.last().ball()->setColor(config->readEntry("Color", "#ffffff"));
4559
players.last().setName(config->readEntry("Name"));
4559
players.last().ball()->setColor(configGroup->readEntry("Color", "#ffffff"));
4560
players.last().setName(configGroup->readEntry("Name"));
4560
4561
players.last().setId(i);
4562
QStringList scores(config->readEntry("Scores",QStringList()));
4563
QStringList scores(configGroup->readEntry("Scores",QStringList()));
4563
4564
QList<int> intscores;
4564
4565
for (QStringList::Iterator it = scores.begin(); it != scores.end(); ++it)
4565
4566
intscores.append((*it).toInt());
4571
4572
void KolfGame::saveScores(KConfig *config)
4573
4574
// wipe out old player info
4574
QStringList groups = config->groupList();
4575
QStringList groups = cfg->groupList();
4575
4576
for (QStringList::Iterator it = groups.begin(); it != groups.end(); ++it)
4577
4578
// this deletes all int groups, ie, the player info groups
4581
4582
config->deleteGroup(*it);
4584
config->setGroup("0 Saved Game");
4585
config->writeEntry("Players", players->count());
4586
config->writeEntry("Course", filename);
4587
config->writeEntry("Current Hole", curHole);
4585
KConfigGroup *configGroup = new KConfigGroup(config->group(QString("0 Saved Game")));
4586
configGroup->writeEntry("Players", players->count());
4587
configGroup->writeEntry("Course", filename);
4588
configGroup->writeEntry("Current Hole", curHole);
4589
4590
for (PlayerList::Iterator it = players->begin(); it != players->end(); ++it)
4591
config->setGroup(QString::number((*it).id()));
4592
config->writeEntry("Name", (*it).name());
4593
config->writeEntry("Color", (*it).ball()->color().name());
4592
configGroup = new KConfigGroup(config->group(QString::number((*it).id())));
4593
configGroup->writeEntry("Name", (*it).name());
4594
configGroup->writeEntry("Color", (*it).ball()->color().name());
4595
4596
QStringList scores;
4596
4597
QList<int> intscores = (*it).scores();
4597
4598
for (QList<int>::Iterator it = intscores.begin(); it != intscores.end(); ++it)
4598
4599
scores.append(QString::number(*it));
4600
config->writeEntry("Scores", scores);
4601
configGroup->writeEntry("Scores", scores);