| 198 | } |
| 199 | |
| 200 | void CMacro::Save(Wisp::CBinaryFileWriter &writer) |
| 201 | { |
| 202 | short size = 12; |
| 203 | short count = 0; |
| 204 | for (auto obj = (CMacroObject *)m_Items; obj != nullptr; obj = (CMacroObject *)obj->m_Next) |
| 205 | { |
| 206 | size += 5; |
| 207 | count++; |
| 208 | if (obj->HaveString()) //with string |
| 209 | { |
| 210 | auto str = ((CMacroObjectString *)obj)->m_String; |
| 211 | size += (short)str.length() + 3; |
| 212 | } |
| 213 | } |
| 214 | |
| 215 | writer.WriteUInt16LE(size); |
| 216 | auto key = Key; |
| 217 | if (Alt) |
| 218 | { |
| 219 | key += MODKEY_ALT; |
| 220 | } |
| 221 | |
| 222 | if (Ctrl) |
| 223 | { |
| 224 | key += MODKEY_CTRL; |
| 225 | } |
| 226 | |
| 227 | if (Shift) |
| 228 | { |
| 229 | key += MODKEY_SHIFT; |
| 230 | } |
| 231 | |
| 232 | writer.WriteInt32LE(key); |
| 233 | writer.WriteUInt16LE(count); |
| 234 | for (auto obj = (CMacroObject *)m_Items; obj != nullptr; obj = (CMacroObject *)obj->m_Next) |
| 235 | { |
| 236 | uint8_t type = 0; |
| 237 | if (obj->HaveString()) |
| 238 | { |
| 239 | type = 2; |
| 240 | } |
| 241 | |
| 242 | writer.WriteUInt8(type); |
| 243 | writer.WriteUInt16LE(obj->Code); |
| 244 | writer.WriteUInt16LE(obj->SubCode); |
| 245 | if (type == 2) //with string |
| 246 | { |
| 247 | auto str = ((CMacroObjectString *)obj)->m_String; |
| 248 | int len = (int)str.length(); |
| 249 | writer.WriteInt16LE(len + 1); |
| 250 | writer.WriteString(str); |
| 251 | } |
| 252 | writer.WriteBuffer(); |
| 253 | } |
| 254 | writer.WriteUInt32LE(0); //EOM |
| 255 | writer.WriteBuffer(); |
| 256 | } |
| 257 |
no test coverage detected