Stefan Schuermans commited on 2019-07-15 19:26:04
Showing 6 changed files, with 54 additions and 49 deletions.
... | ... |
@@ -73,8 +73,12 @@ public: |
73 | 73 |
/// check for update of configuration |
74 | 74 |
virtual void updateConfig() final; |
75 | 75 |
|
76 |
- /// check for update of configuration (derived game), return true on update |
|
77 |
- virtual bool updateConfigGame() = 0; |
|
76 |
+ /** |
|
77 |
+ * @brief check for update of configuration (derived game) |
|
78 |
+ * @param[in,out] doReinit set to true to ask for reinitialization |
|
79 |
+ * @param[in,out] doRedraw set to true to ask for redrawing |
|
80 |
+ */ |
|
81 |
+ virtual void updateConfigGame(bool &doReinit, bool &doRedraw) = 0; |
|
78 | 82 |
|
79 | 83 |
/// callback when requested time reached |
80 | 84 |
virtual void timeCall(); |
... | ... |
@@ -81,21 +81,26 @@ Pong::~Pong() |
81 | 81 |
} |
82 | 82 |
} |
83 | 83 |
|
84 |
-/// check for update of configuration (derived game), return true on update |
|
85 |
-bool Pong::updateConfigGame() |
|
84 |
+/** |
|
85 |
+ * @brief check for update of configuration (derived game) |
|
86 |
+ * @param[in,out] doReinit set to true to ask for reinitialization |
|
87 |
+ * @param[in,out] doRedraw set to true to ask for redrawing |
|
88 |
+ */ |
|
89 |
+void Pong::updateConfigGame(bool &doReinit, bool &doRedraw) |
|
86 | 90 |
{ |
87 |
- bool ret = false; |
|
88 |
- |
|
89 |
- // color file was modified -> convert color, return true for update |
|
90 |
- // cfg value file was updated -> read new cfg value, return true for update |
|
91 |
- if (colorUpdate(m_fileBallColor, m_ballColor)) { ret = true; } |
|
92 |
- if (colorUpdate(m_fileLineColor, m_lineColor)) { ret = true; } |
|
93 |
- if (colorUpdate(m_filePadColor, m_padColor)) { ret = true; } |
|
94 |
- if (colorUpdate(m_fileComputerColor, m_computerColor)) { ret = true; } |
|
95 |
- if (colorUpdate(m_fileScoreColor, m_scoreColor)) { ret = true; } |
|
96 |
- if (colorUpdate(m_fileGoalColor, m_goalColor)) { ret = true; } |
|
97 |
- if (valueUpdate(m_fileDelay, c_delayDescr, m_delay)) { ret = true; } |
|
98 |
- if (valueUpdate(m_fileMaxScore, c_maxScoreDescr, m_maxScore)) { ret = true; } |
|
91 |
+ (void)doReinit; |
|
92 |
+ |
|
93 |
+ // color file was modified -> convert color, ask for redraw |
|
94 |
+ if (colorUpdate(m_fileBallColor, m_ballColor)) { doRedraw = true; } |
|
95 |
+ if (colorUpdate(m_fileLineColor, m_lineColor)) { doRedraw = true; } |
|
96 |
+ if (colorUpdate(m_filePadColor, m_padColor)) { doRedraw = true; } |
|
97 |
+ if (colorUpdate(m_fileComputerColor, m_computerColor)) { doRedraw = true; } |
|
98 |
+ if (colorUpdate(m_fileScoreColor, m_scoreColor)) { doRedraw = true; } |
|
99 |
+ if (colorUpdate(m_fileGoalColor, m_goalColor)) { doRedraw = true; } |
|
100 |
+ |
|
101 |
+ // cfg value file was updated -> read new cfg value, no reinit/redraw |
|
102 |
+ valueUpdate(m_fileDelay, c_delayDescr, m_delay); |
|
103 |
+ valueUpdate(m_fileMaxScore, c_maxScoreDescr, m_maxScore); |
|
99 | 104 |
|
100 | 105 |
// sound name file was modified -> re-read sound name, no other update needed |
101 | 106 |
soundUpdate(m_fileLeftPlayerSound); |
... | ... |
@@ -104,8 +109,6 @@ bool Pong::updateConfigGame() |
104 | 109 |
soundUpdate(m_fileOtherScoreSound); |
105 | 110 |
soundUpdate(m_fileWinSound); |
106 | 111 |
soundUpdate(m_fileLoseSound); |
107 |
- |
|
108 |
- return ret; |
|
109 | 112 |
} |
110 | 113 |
|
111 | 114 |
/** |
... | ... |
@@ -53,8 +53,12 @@ private: |
53 | 53 |
const Pong & operator=(const Pong &that); |
54 | 54 |
|
55 | 55 |
public: |
56 |
- /// check for update of configuration (derived game), return true on update |
|
57 |
- virtual bool updateConfigGame(); |
|
56 |
+ /** |
|
57 |
+ * @brief check for update of configuration (derived game) |
|
58 |
+ * @param[in,out] doReinit set to true to ask for reinitialization |
|
59 |
+ * @param[in,out] doRedraw set to true to ask for redrawing |
|
60 |
+ */ |
|
61 |
+ virtual void updateConfigGame(bool &doReinit, bool &doRedraw); |
|
58 | 62 |
|
59 | 63 |
/** |
60 | 64 |
* @brief check if accepting new operator connection is possible |
... | ... |
@@ -71,36 +71,28 @@ Tetris::~Tetris() |
71 | 71 |
} |
72 | 72 |
} |
73 | 73 |
|
74 |
-/// check for update of configuration (derived game), return true on update |
|
75 |
-bool Tetris::updateConfigGame() |
|
74 |
+/** |
|
75 |
+ * @brief check for update of configuration (derived game) |
|
76 |
+ * @param[in,out] doReinit set to true to ask for reinitialization |
|
77 |
+ * @param[in,out] doRedraw set to true to ask for redrawing |
|
78 |
+ */ |
|
79 |
+void Tetris::updateConfigGame(bool &doReinit, bool &doRedraw) |
|
76 | 80 |
{ |
77 |
- bool ret = false; |
|
81 |
+ (void)doReinit; |
|
78 | 82 |
|
79 |
- // color file was modified -> convert color, return true for update |
|
80 |
- // cfg value file was updated -> read new cfg value, return true for update |
|
81 |
- if (colorUpdate(m_fileStoneColor, m_stoneColor)) { |
|
82 |
- ret = true; |
|
83 |
- } |
|
84 |
- if (valueUpdate(m_fileDelay, c_delayDescr, m_delay)) { |
|
85 |
- ret = true; |
|
86 |
- } |
|
87 |
- if (valueUpdate(m_fileDropDelay, c_dropDelayDescr, m_dropDelay)) { |
|
88 |
- ret = true; |
|
89 |
- } |
|
90 |
- if (valueUpdate(m_fileBlinkDelay, c_blinkDelayDescr, m_blinkDelay)) { |
|
91 |
- ret = true; |
|
92 |
- } |
|
93 |
- if (valueUpdate(m_fileGameOverDelay, c_gameOverDelayDescr, |
|
94 |
- m_gameOverDelay)) { |
|
95 |
- ret = true; |
|
96 |
- } |
|
83 |
+ // color file was modified -> convert color, ask for redraw |
|
84 |
+ if (colorUpdate(m_fileStoneColor, m_stoneColor)) { doRedraw = true; } |
|
97 | 85 |
|
98 |
- // sound name file was modified -> re-read sound name, no other update needed |
|
86 |
+ // delay cfg value file was updated -> read new delay cfg value, no re-* |
|
87 |
+ valueUpdate(m_fileDelay, c_delayDescr, m_delay); |
|
88 |
+ valueUpdate(m_fileDropDelay, c_dropDelayDescr, m_dropDelay); |
|
89 |
+ valueUpdate(m_fileBlinkDelay, c_blinkDelayDescr, m_blinkDelay); |
|
90 |
+ valueUpdate(m_fileGameOverDelay, c_gameOverDelayDescr, m_gameOverDelay); |
|
91 |
+ |
|
92 |
+ // sound name file was modified -> re-read sound name, no reinit/draw needed |
|
99 | 93 |
soundUpdate(m_fileStartSound); |
100 | 94 |
soundUpdate(m_fileRowCompleteSound); |
101 | 95 |
soundUpdate(m_fileGameOverSound); |
102 |
- |
|
103 |
- return ret; |
|
104 | 96 |
} |
105 | 97 |
|
106 | 98 |
/** |
... | ... |
@@ -70,8 +70,12 @@ private: |
70 | 70 |
const Tetris & operator=(const Tetris &that); |
71 | 71 |
|
72 | 72 |
public: |
73 |
- /// check for update of configuration (derived game), return true on update |
|
74 |
- virtual bool updateConfigGame(); |
|
73 |
+ /** |
|
74 |
+ * @brief check for update of configuration (derived game) |
|
75 |
+ * @param[in,out] doReinit set to true to ask for reinitialization |
|
76 |
+ * @param[in,out] doRedraw set to true to ask for redrawing |
|
77 |
+ */ |
|
78 |
+ virtual void updateConfigGame(bool &doReinit, bool &doRedraw); |
|
75 | 79 |
|
76 | 80 |
/** |
77 | 81 |
* @brief check if accepting new operator connection is possible |
78 | 82 |