| 100 | { |
| 101 | if (state) Qi::popText->Popup(Qi::ui.pop.time, ParseMacro(Qi::ui.pop.swe.t, macro->name, 0), Qi::ui.pop.swe.c); |
| 102 | else Qi::popText->Popup(Qi::ui.pop.time, ParseMacro(Qi::ui.pop.swd.t, macro->name, 0), Qi::ui.pop.swd.c); |
| 103 | } |
| 104 | else if (macro->mode == Macro::down) |
| 105 | { |
| 106 | if (state) Qi::popText->Popup(Qi::ui.pop.time, ParseMacro(Qi::ui.pop.dwe.t, macro->name, macro->count), Qi::ui.pop.dwe.c); |
| 107 | else Qi::popText->Popup(Qi::ui.pop.time, ParseMacro(Qi::ui.pop.dwd.t, macro->name, macro->count), Qi::ui.pop.dwd.c); |
| 108 | } |
| 109 | else if (macro->mode == Macro::up) |
| 110 | { |
| 111 | if (state) Qi::popText->Popup(Qi::ui.pop.time, ParseMacro(Qi::ui.pop.upe.t, macro->name, macro->count), Qi::ui.pop.upe.c); |
| 112 | else Qi::popText->Popup(Qi::ui.pop.time, ParseMacro(Qi::ui.pop.upd.t, macro->name, macro->count), Qi::ui.pop.upd.c); |
| 113 | } |
| 114 | } |
| 115 | void SoundPlay(const QString& sound, bool sync) |
| 116 | { |
| 117 | Sound::SoundClose(); |
| 118 | PlaySoundW(nullptr, GetModuleHandleW(nullptr), SND_ASYNC); |
| 119 | if (!sound.isEmpty()) |
| 120 | { |
| 121 | int index = Qi::ui.sounds.indexOf(sound); |
| 122 | if (index != -1) |
| 123 | { |
| 124 | PlaySoundW((const wchar_t*)Qi::ui.sounds.at(index).utf16(), GetModuleHandleW(nullptr), (sync ? SND_SYNC : SND_ASYNC) | SND_RESOURCE); |
| 125 | } |
| 126 | else if (sound.indexOf(".wav") == -1) |
| 127 | { |
| 128 | Sound::SoundClose(); |
| 129 | Sound::SoundOpen((const wchar_t*)sound.utf16()); |
| 130 | Sound::SoundPlay(sync); |
| 131 | } |
| 132 | else |
| 133 | { |
| 134 | Sound::WavePlay((const wchar_t*)sound.utf16(), sync); |
| 135 | } |
| 136 | } |
| 137 | } |
| 138 | |
| 139 | void SmoothMove(const int sx, const int sy, const int dx, const int dy, const int speed, std::function<void(int x, int y, int stepx, int stepy)> CallBack) |
| 140 | { |
| 141 | int cx = dx - sx; |
| 142 | int cy = dy - sy; |
| 143 | |
| 144 | int px = 0; |
| 145 | int py = 0; |
| 146 | |
| 147 | float step = (float)speed / 300.0f; |
| 148 | if (step < 0.01f) step = 0.01f; |
| 149 | if (step > 0.99f) step = 0.99f; |
| 150 | |
| 151 | for (float i = 0.0f; true; i += step) |
| 152 | { |
| 153 | if (i > 1.0f) i = 1.0f; |
| 154 | int x = sx + (int)((float)cx * i); |
| 155 | int y = sy + (int)((float)cy * i); |
| 156 | if (i < 1.0f) |
| 157 | { |
| 158 | CallBack(x, y, x - px, y - py); |