< Projects | GamesRevision as of 20:51, 7 March 2012 by Majewsky (talk | contribs) (→Difficulty)(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff) This document describes the changes introduced with libkdegames v5, which first appeared in the KDE 4.9 release. Contents 1 New components 2 Removed components 3 Reworked components 3.1 Difficulty New components KgSound provides a simple API for playback of short event sounds. Low latency is achieved through the use of OpenAL, with a Phonon fallback if the required libraries are not available. Also, multiple new components have been added which replace existing components. These can be identified by the common class name prefix "Kg". See Reworked components for details. Removed components The KGGZ framework has been removed completely. KGameLCD — Use QLCDNumber instead. KGameMisc — Instead of a random name, we advise to use generic names where appropriate. KGameProgress — Use QProgressBar instead. KGameSvgDigits — If you need SVG digits, include them in your own SVG theme. KGrid2D — You'll need to do the math yourself. Reworked components Difficulty KGameDifficulty has been replaced by the KgDifficulty and KgDifficultyLevel classes. KgDifficulty stores the current level by itself, and allows for multiple KgDifficulty instances at the same time, although a singleton is provided by the Kg::difficulty() function. The following table shows how to port common uses of KGameDifficulty to this singleton: Replace this... ...by this Comment KGameDifficulty::standardLevel KgDifficultyLevel::StandardLevel KGameDifficulty::Medium etc. KgDifficultyLevel::Medium etc. KGameDifficulty::addStandardLevel(level) Kg::difficulty()->addStandardLevel(level) As a convenience, consider to use the new addStandardLevelRange() method. KGameDifficulty::init(window, receiver, slot) KgDifficultyGUI::init(window); QObject::connect(Kg::difficulty(),SLOT(currentLevelChanged(const KgDifficultyLevel*)),receiver, slot); Change the slot to the new signature. The old signature contained a standard level argument: Use the "standardLevel" property of the new argument instead. KGameDifficulty::level() Kg::difficultyLevel() KGameDifficulty::setLevel(level) Kg::difficulty()->select(level) If used to restore the selected difficulty from the config file, delete the whole call and your custom config key. KgDifficulty remembers the level selection by itself. Please refer to the APIDOX for details, e.g. how to specify a default difficulty for the first run. KGameDifficulty::levelWeights(),KGameDifficulty::localizedLevelStrings(),etc. while setting up a KScoreDialog dialog->initFromDifficulty(Kg::difficulty()); If you need the QMaps from these KGameDifficulty functions, you can construct them by iterating over the KgDifficultyLevels. levelWeights maps hardness->key and localizedLevelStrings maps key->title. KGameDifficulty::setRestartOnChange(roc) Kg::difficulty()->setGameRunning(roc && running) These two properties of KGameDifficulty are redundant: If both are true, the user will be asked for confirmation before the level is changed. If you do not want this, just do not use the setGameRunning method. KGameDifficulty::setRunning(running) KGameDifficulty::setEnabled() Kg::difficulty()->setEditable() The property has been renamed to clarify its purpose. Retrieved from "https://techbase.kde.org/index.php?title=Projects/Games/Porting_to_libkdegames_v5&oldid=69184" Content is available under Creative Commons License SA 4.0 unless otherwise noted.