You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

578 lines
16 KiB

​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. #include "flyHunterWidget.h"
  2. #include "../../components/object/objectFlyHunter.h"
  3. #include "OSDWidget.h"
  4. CSTR c_comName = NULL;
  5. bool a_bg = false;
  6. void reconnect(void) {
  7. mHNT->connectVia(c_comName);
  8. //a_bg = !a_bg;
  9. //classGUI_SDL::getInstance()->alterateBackground(a_bg);
  10. };
  11. static CSTR basic_mode_names[8] = {
  12. (CSTR)"CUSTOM",
  13. (CSTR)"TEST",
  14. (CSTR)"AUTO",
  15. (CSTR)"GUIDED",
  16. (CSTR)"STABIL",
  17. (CSTR)"HIL",
  18. (CSTR)"MANUAL",
  19. (CSTR)"ARMED"
  20. };
  21. sdlFlyHunterWidget::sdlFlyHunterWidget(int x, int y, int w, int h, sdlCoreWidget* pParent):sdlCoreWidget(x,y,w,h,false,pParent){
  22. m_pFH = NULL;
  23. m_pCtrlTex = NULL;
  24. m_pName = NULL;
  25. m_pType = NULL;
  26. m_pMode = NULL;
  27. m_pCustomMode = NULL;
  28. m_bBlinkingLVL = false;
  29. m_bBasicModeActual = false;
  30. m_pOSD = NULL;
  31. if (c_comName == NULL) {
  32. c_comName = (CSTR)malloc(20);
  33. if (c_comName != NULL) {
  34. memset(c_comName, 0, 20);
  35. };
  36. };
  37. m_bBlinkingTO = getMilliseconds() + 500;
  38. m_bStatusCheckerCnt = 5;
  39. m_bStatusFH = 0;
  40. m_bStatusRadio = 0;
  41. m_bStatusDrone = 0;
  42. m_bStatusGPS = 0;
  43. m_pComPorts = new sdlScrollListWidget(0, 43, 200, 60, 15, true, this);
  44. m_pComPorts->addItem((CSTR)"COM1");
  45. m_pComPorts->addItem((CSTR)"COM2");
  46. m_pComPorts->addItem((CSTR)"COM3");
  47. m_pComPorts->addItem((CSTR)"COM4");
  48. m_pComPorts->addItem((CSTR)"COM5");
  49. m_pComPorts->addItem((CSTR)"COM6");
  50. m_pComPorts->addItem((CSTR)"COM7");
  51. m_pComPorts->addItem((CSTR)"COM8");
  52. m_pComPorts->setParamPtr(c_comName);
  53. m_pComPorts->selectItem(3);
  54. m_pReconnect = new sdlSimpleButtonWidget((CSTR)"RECONNECT", 202, 43, 80, 60, this);
  55. m_pReconnect->Pushed = reconnect;
  56. //General Info Panel
  57. m_pFHNfoPanel = new sdlSimplePanel(284, 43, 200, 60, true, this);
  58. m_pNameLabel = new sdlLabel((CSTR)"Noname", 0, 0, 200, 12, m_pFHNfoPanel, 10);
  59. m_pNameLabel->setAlign(ALIGN_LEFT);
  60. m_pNameLabel->setColor(0, 0, 0);
  61. m_pTypeLabel = new sdlLabel((CSTR)"Unknown", 0, 12, 200, 12, m_pFHNfoPanel, 10);
  62. m_pTypeLabel->setAlign(ALIGN_LEFT);
  63. m_pTypeLabel->setColor(0, 0, 0);
  64. m_pModeLabel = new sdlLabel((CSTR)"Unknown", 0, 24, 200, 12, m_pFHNfoPanel, 10);
  65. m_pModeLabel->setAlign(ALIGN_LEFT);
  66. m_pModeLabel->setColor(0, 0, 0);
  67. m_pCustomModeLabel = new sdlLabel((CSTR)"Unknown", 0, 36, 200, 12, m_pFHNfoPanel, 10);
  68. m_pCustomModeLabel->setAlign(ALIGN_LEFT);
  69. m_pCustomModeLabel->setColor(0, 0, 0);
  70. //GpsSat-Power Info Panel
  71. //m_pFHBasicModePanel = new sdlSimplePanel(0, 105, 300, 60, true, this);
  72. for (int i = 0; i < 8; i++) {
  73. m_pActualModeFlag[i] = new sdlSimpleButtonWidget(basic_mode_names[i], i*75, 105, 70, 17, this);
  74. m_pActualModeFlag[i]->setToggle(true);
  75. m_pActualModeFlag[i]->setReadOnly(true);
  76. };
  77. m_pSetModeButton = new sdlSimpleButtonWidget((CSTR)"SET BASIC MODE", 0, 125, m_sGeometry.w, 20, this);
  78. //for (int i = 0; i < 8; i++) {
  79. // m_pNewModeFlag[i] = new sdlSimpleButtonWidget(basic_mode_names[i], i * 75, 125, 70, 17, this);
  80. // m_pNewModeFlag[i]->setToggle(true);
  81. //};
  82. //m_pSetModeButton = new sdlSimpleButtonWidget((CSTR)"SET BASIC MODE", 0, 145, m_sGeometry.w, 20, this);
  83. //BigButtons
  84. int z = 170;
  85. m_pArmMode = new sdlButtonWidget((CSTR)"ARM", 0, z, w, 40, this);
  86. m_pArmMode->setToggle(true);
  87. z += 45;
  88. m_pLandNow = new sdlButtonWidget((CSTR)"Land Now!", 0, z, 200, 40, this);
  89. m_pTakeOff = new sdlButtonWidget((CSTR)"Take Off", 205, z, 200, 40, this);
  90. z += 45;
  91. m_pFlyHome = new sdlButtonWidget((CSTR)"Fly Home", 0, z, 200, 40, this);
  92. m_pSetHome = new sdlButtonWidget((CSTR)"Set Home", 205, z, 200, 40, this);
  93. z += 45;
  94. m_pLockXY = new sdlButtonWidget((CSTR)"Lock X-Y", 0, z, 200, 40, this);
  95. m_pLockXY->setToggle(true);
  96. m_pLockYZ = new sdlButtonWidget((CSTR)"Lock Y-Z", 205, z, 200, 40, this);
  97. m_pLockYZ->setToggle(true);
  98. z += 45;
  99. m_pHoldPosition = new sdlButtonWidget((CSTR)"Hold Position", 0, z, w, 40, this);
  100. m_pHoldPosition->setToggle(true);
  101. m_pArmMode->setDisabled();
  102. m_pLandNow->setDisabled();
  103. m_pTakeOff->setDisabled();
  104. m_pFlyHome->setDisabled();
  105. m_pSetHome->setDisabled();
  106. m_pLockXY->setDisabled();
  107. m_pLockYZ->setDisabled();
  108. m_pHoldPosition->setDisabled();
  109. sdlGraphicElement::setType(GEL_PANEL);
  110. m_pGUI->registerGEL(this);
  111. };
  112. sdlFlyHunterWidget::~sdlFlyHunterWidget() {
  113. if (m_pNameLabel != NULL)delete(m_pNameLabel);
  114. if (m_pTypeLabel != NULL)delete(m_pTypeLabel);
  115. if (m_pTypeLabel != NULL)delete(m_pTypeLabel);
  116. if (m_pTypeLabel != NULL)delete(m_pTypeLabel);
  117. if (m_pTypeLabel != NULL)delete(m_pTypeLabel);
  118. if (m_pTypeLabel != NULL)delete(m_pTypeLabel);
  119. if (m_pTypeLabel != NULL)delete(m_pTypeLabel);
  120. };
  121. void sdlFlyHunterWidget::drawBefore(SDL_Renderer* pRenderer) {
  122. //Update Video
  123. if (m_bStatusDrone == 3) {
  124. if (m_pOSD != NULL) {
  125. //m_pOSD->setPitch(m_pFH->getBodyPitch());
  126. m_pOSD->setRoll(m_pFH->getBodyRoll());
  127. //m_pOSD->setYaw(m_pFH->getBodyYaw());
  128. mavlink_vfr_hud_t* tVals;
  129. tVals = m_pFH->getVFRData();
  130. if (tVals != NULL) {
  131. m_pOSD->setAlt(tVals->alt);
  132. m_pOSD->setAirSpeed(tVals->airspeed);
  133. m_pOSD->setClimbRate(tVals->climb);
  134. m_pOSD->setGroundSpeed(tVals->groundspeed);
  135. m_pOSD->setMagHeading(tVals->heading);
  136. m_pOSD->setThrottle(tVals->throttle);
  137. };
  138. mavlink_power_status_t* tPow;
  139. tPow = m_pFH->getPowerStatusData();
  140. if (tPow != NULL) {
  141. m_pOSD->setVoltage(tPow->Vcc/1000.f);
  142. }
  143. };
  144. }
  145. if (m_bBlinkingTO < getMilliseconds()) {
  146. m_bBlinkingTO = getMilliseconds() + 500;
  147. m_bBlinkingLVL = !m_bBlinkingLVL;
  148. if (m_bStatusCheckerCnt) {
  149. m_bStatusCheckerCnt--;
  150. } else {
  151. m_bStatusCheckerCnt = 5;
  152. if (m_pFH) {
  153. if (m_bStatusFH == 1) {
  154. if (m_pFH->isRadiosConnected()) { // Com port is OK
  155. m_bStatusFH = 3;
  156. m_bStatusRadio = 1;
  157. m_bStatusDrone = 0;
  158. } else {
  159. m_bStatusFH = 2;
  160. m_bStatusRadio = 0;
  161. m_bStatusDrone = 0;
  162. m_bStatusGPS = 0;
  163. };
  164. } else if (m_bStatusFH == 2 ) {
  165. // Check if reconnected
  166. if ( m_pFH->isRadiosConnected() ) m_bStatusFH = 1;
  167. } else {
  168. if ( m_pFH->isRadiosConnected()) { // Com port is OK
  169. if (m_bStatusRadio == 1) {
  170. if (m_pFH->isVehicleAttached()) {
  171. m_bStatusRadio = 3;
  172. m_bStatusDrone = 1;
  173. };
  174. };
  175. if ( m_bStatusDrone ) {
  176. //Check if Pairing Done amd check for GPS!
  177. if (m_pFH->isGpsPresent()) {
  178. m_bStatusDrone = 3;
  179. m_bStatusGPS = 1;
  180. m_pArmMode->setEnabled();
  181. m_pLandNow->setEnabled();
  182. m_pTakeOff->setEnabled();
  183. m_pFlyHome->setEnabled();
  184. m_pSetHome->setEnabled();
  185. m_pLockXY->setEnabled();
  186. m_pLockYZ->setEnabled();
  187. m_pHoldPosition->setEnabled();
  188. if (!m_bBasicModeActual) {
  189. uint8_t cs = m_pFH->getVehicleSystemMode();
  190. for (int i = 0; i < 8; i++) {
  191. m_pActualModeFlag[i]->setReadOnly(false);
  192. if ((cs & (1 << i)) == (1 << i)) {
  193. m_pActualModeFlag[i]->setToggled(true);
  194. } else {
  195. m_pActualModeFlag[i]->setToggled(false);
  196. };
  197. };
  198. m_bBasicModeActual = true;
  199. };
  200. };
  201. };
  202. } else {
  203. m_bStatusFH = 2;
  204. m_bStatusRadio = 0;
  205. m_bStatusDrone = 0;
  206. m_bStatusGPS = 0;
  207. m_pArmMode->setDisabled();
  208. m_pLandNow->setDisabled();
  209. m_pTakeOff->setDisabled();
  210. m_pFlyHome->setDisabled();
  211. m_pSetHome->setDisabled();
  212. m_pLockXY->setDisabled();
  213. m_pLockYZ->setDisabled();
  214. m_pHoldPosition->setDisabled();
  215. uint8_t cs = 0;
  216. for (int i = 0; i < 8; i++) {
  217. m_pActualModeFlag[i]->setToggled(false);
  218. m_pActualModeFlag[i]->setReadOnly(true);
  219. };
  220. m_bBasicModeActual = false;
  221. };
  222. };
  223. if (m_bStatusFH == 0)m_bStatusFH = 1;
  224. };
  225. };
  226. };
  227. if (m_pFH) {
  228. if (m_pCtrlTex != NULL) {
  229. int z = ( m_sGeometry.w - 108 ) >> 2;
  230. SDL_Rect tS, tD;
  231. tS.x = 0; tS.y = 40;
  232. tS.w = 6; tS.h = 40;
  233. tD = tS;
  234. tD.y = 0;
  235. SDL_RenderCopy(pRenderer, m_pCtrlTex->texture, &tS, &tD);
  236. tS.x = 6; tS.y = 40;
  237. tS.w = 6; tS.h = 40;
  238. tD.x = 6; tD.w = z;
  239. SDL_RenderCopy(pRenderer, m_pCtrlTex->texture, &tS, &tD);
  240. if (m_bStatusRadio == 0) {
  241. tS.x = 110; tS.y = 40;
  242. tS.w = 32; tS.h = 40;
  243. tD.x = z + 6; tD.w = 32;
  244. } else {
  245. tS.x = 110; tS.y = 80;
  246. tS.w = 32; tS.h = 40;
  247. tD.x = z + 6; tD.w = 32;
  248. };
  249. SDL_RenderCopy(pRenderer, m_pCtrlTex->texture, &tS, &tD);
  250. if (m_bStatusRadio == 0) {
  251. tS.x = 6; tS.y = 0;
  252. tS.w = 6; tS.h = 40;
  253. tD.x = z + 6 + 32; tD.w = z;
  254. } else {
  255. tS.x = 6; tS.y = 40;
  256. tS.w = 6; tS.h = 40;
  257. tD.x = z + 6 + 32; tD.w = z;
  258. };
  259. SDL_RenderCopy(pRenderer, m_pCtrlTex->texture, &tS, &tD);
  260. if (m_bStatusRadio == 0) {
  261. tS.x = 110; tS.y = 0;
  262. tS.w = 32; tS.h = 40;
  263. tD.x = (z << 1) + 6 + 32; tD.w = 32;
  264. } else {
  265. if (m_bStatusDrone == 0) {
  266. tS.x = 110; tS.y = 40;
  267. tS.w = 32; tS.h = 40;
  268. tD.x = (z << 1) + 6 + 32; tD.w = 32;
  269. } else {
  270. tS.x = 110; tS.y = 80;
  271. tS.w = 32; tS.h = 40;
  272. tD.x = (z << 1) + 6 + 32; tD.w = 32;
  273. };
  274. };
  275. SDL_RenderCopy(pRenderer, m_pCtrlTex->texture, &tS, &tD);
  276. if (m_bStatusDrone == 0) {
  277. tS.x = 6; tS.y = 0;
  278. tS.w = 6; tS.h = 40;
  279. tD.x = (z << 1) + 6 + 64; tD.w = z;
  280. } else {
  281. tS.x = 6; tS.y = 40;
  282. tS.w = 6; tS.h = 40;
  283. tD.x = (z << 1) + 6 + 64; tD.w = z;
  284. };
  285. SDL_RenderCopy(pRenderer, m_pCtrlTex->texture, &tS, &tD);
  286. if (m_bStatusDrone == 0) {
  287. tS.x = 110; tS.y = 0;
  288. tS.w = 32; tS.h = 40;
  289. tD.x = (z * 3) + 6 + 64; tD.w = 32;
  290. } else {
  291. if (m_bStatusGPS == 0) {
  292. tS.x = 110; tS.y = 40;
  293. tS.w = 32; tS.h = 40;
  294. tD.x = (z * 3) + 6 + 64; tD.w = 32;
  295. } else {
  296. tS.x = 110; tS.y = 80;
  297. tS.w = 32; tS.h = 40;
  298. tD.x = (z * 3) + 6 + 64; tD.w = 32;
  299. };
  300. };
  301. SDL_RenderCopy(pRenderer, m_pCtrlTex->texture, &tS, &tD);
  302. if (m_bStatusGPS == 0) {
  303. tS.x = 6; tS.y = 0;
  304. tS.w = 6; tS.h = 40;
  305. tD.x = (z * 3) + 6 + 96; tD.w = z;
  306. } else {
  307. tS.x = 6; tS.y = 40;
  308. tS.w = 6; tS.h = 40;
  309. tD.x = (z * 3) + 6 + 96; tD.w = z;
  310. };
  311. SDL_RenderCopy(pRenderer, m_pCtrlTex->texture, &tS, &tD);
  312. if (m_bStatusGPS == 0) {
  313. tS.x = 280; tS.y = 0;
  314. tS.w = 6; tS.h = 40;
  315. tD.x = (z << 2) + 6 + 96; tD.w = 6;
  316. } else {
  317. tS.x = 280; tS.y = 80;
  318. tS.w = 6; tS.h = 40;
  319. tD.x = (z << 2) + 6 + 96; tD.w = 6;
  320. };
  321. SDL_RenderCopy(pRenderer, m_pCtrlTex->texture, &tS, &tD);
  322. tS.y = 122;
  323. tD.y = tD.h = tD.w = tS.w = tS.h = 13;
  324. tD.x = z;
  325. if (m_bStatusFH == 0) {
  326. tS.x = 16;
  327. } else if (m_bStatusFH == 1) {
  328. if (m_bBlinkingLVL) {
  329. tS.x = 30;
  330. } else {
  331. tS.x = 16;
  332. };
  333. } else if (m_bStatusFH == 2) {
  334. tS.x = 2;
  335. } else {
  336. tS.x = 30;
  337. };
  338. SDL_RenderCopy(pRenderer, m_pCtrlTex->texture, &tS, &tD);
  339. tD.x = (z << 1) + 32;
  340. if (m_bStatusRadio == 0) {
  341. tS.x = 16;
  342. } else if (m_bStatusRadio == 1) {
  343. if (m_bBlinkingLVL) {
  344. tS.x = 30;
  345. } else {
  346. tS.x = 16;
  347. };
  348. } else if (m_bStatusRadio == 2) {
  349. tS.x = 2;
  350. } else {
  351. tS.x = 30;
  352. };
  353. SDL_RenderCopy(pRenderer, m_pCtrlTex->texture, &tS, &tD);
  354. tD.x = (z * 3) + 64;
  355. if (m_bStatusDrone == 0) {
  356. tS.x = 16;
  357. } else if (m_bStatusDrone == 1) {
  358. if (m_bBlinkingLVL) {
  359. tS.x = 30;
  360. } else {
  361. tS.x = 16;
  362. };
  363. } else if (m_bStatusDrone == 2) {
  364. tS.x = 2;
  365. } else {
  366. tS.x = 30;
  367. };
  368. SDL_RenderCopy(pRenderer, m_pCtrlTex->texture, &tS, &tD);
  369. tS.x = 6; tS.y = 174;
  370. tD.h = tD.w = tS.w = tS.h = 35;
  371. tD.x = 6 + (z - 35) >> 1; tD.y = 4;
  372. SDL_RenderCopy(pRenderer, m_pCtrlTex->texture, &tS, &tD);
  373. if (m_bStatusRadio == 0) {
  374. tS.y = 137;
  375. } else {
  376. tS.y = 174;
  377. };
  378. tS.x = 152; tD.h = tD.w = tS.w = tS.h = 35; tD.x = 6 + 2 * z + 64 + (z - 35) >> 1; tD.y = 4;
  379. SDL_RenderCopy(pRenderer, m_pCtrlTex->texture, &tS, &tD);
  380. if (m_bStatusDrone == 0) {
  381. tS.y = 137;
  382. } else {
  383. tS.y = 174;
  384. };
  385. tS.x = 88;
  386. tD.w = tS.w = 58; tD.h = tS.h = 35;
  387. tD.x = 6 + 4 * z + 105 + (z - 35) >> 1; tD.y = 4;
  388. SDL_RenderCopy(pRenderer, m_pCtrlTex->texture, &tS, &tD);
  389. if (m_bStatusGPS == 0) {
  390. tS.y = 137;
  391. } else {
  392. tS.y = 174;
  393. };
  394. tS.x = 51;
  395. tD.h = tD.w = tS.w = tS.h = 35;
  396. tD.x = 6 + 6 * z + 192 + (z - 35) >> 1; tD.y = 4;
  397. SDL_RenderCopy(pRenderer, m_pCtrlTex->texture, &tS, &tD);
  398. };
  399. CSTR tPtr;
  400. if ( m_bStatusDrone == 3 ) {
  401. tPtr = m_pFH->getVehicleName();
  402. if (tPtr != m_pName) {
  403. m_pName = tPtr;
  404. m_pNameLabel->setText(m_pName);
  405. m_pNameLabel->setBgColor(255, 255, 0, 255);
  406. };
  407. tPtr = m_pFH->getCtrlName();
  408. if (tPtr != m_pType) {
  409. m_pType = tPtr;
  410. m_pTypeLabel->setText(m_pType);
  411. m_pTypeLabel->setBgColor(255, 255, 0, 255);
  412. };
  413. tPtr = m_pFH->getVehicleSystemModeName();
  414. if (tPtr != m_pMode) {
  415. m_pMode = tPtr;
  416. m_pModeLabel->setText(m_pMode);
  417. m_pModeLabel->setBgColor(255, 255, 0, 255);
  418. };
  419. tPtr = m_pFH->getVehicleAutoPilotModeName();
  420. if (tPtr != m_pCustomMode) {
  421. m_pCustomMode = tPtr;
  422. m_pCustomModeLabel->setText(m_pCustomMode);
  423. m_pCustomModeLabel->setBgColor(255, 255, 0, 255);
  424. };
  425. } else {
  426. if (m_pName || m_pType) {
  427. m_pName = NULL;
  428. m_pType = NULL;
  429. m_pMode = NULL;
  430. m_pCustomMode = NULL;
  431. m_pNameLabel->setText((CSTR)"Noname");
  432. m_pTypeLabel->setText((CSTR)"Unknown");
  433. m_pModeLabel->setText((CSTR)"Unknown");
  434. m_pCustomModeLabel->setText((CSTR)"Unknown");
  435. m_pNameLabel->setBgColor(255, 255, 0, 50);
  436. m_pTypeLabel->setBgColor(255, 255, 0, 50);
  437. };
  438. };
  439. } else {
  440. if (m_pCtrlTex != NULL) {
  441. int z = (m_sGeometry.w - 108) >> 2;
  442. SDL_Rect tS, tD;
  443. tS.x = 0; tS.y = 0;
  444. tS.w = 6; tS.h = 40;
  445. tD = tS;
  446. SDL_RenderCopy(pRenderer, m_pCtrlTex->texture, &tS, &tD);
  447. tS.x = 6; tS.y = 0;
  448. tS.w = 6; tS.h = 40;
  449. tD.x = 6; tD.w = z;
  450. SDL_RenderCopy(pRenderer, m_pCtrlTex->texture, &tS, &tD);
  451. tS.x = 110; tS.y = 0;
  452. tS.w = 32; tS.h = 40;
  453. tD.x = z + 6; tD.w = 32;
  454. SDL_RenderCopy(pRenderer, m_pCtrlTex->texture, &tS, &tD);
  455. tS.x = 6; tS.y = 0;
  456. tS.w = 6; tS.h = 40;
  457. tD.x = z + 6 + 32; tD.w = z;
  458. SDL_RenderCopy(pRenderer, m_pCtrlTex->texture, &tS, &tD);
  459. tS.x = 110; tS.y = 0;
  460. tS.w = 32; tS.h = 40;
  461. tD.x = (z << 1) + 6 + 32; tD.w = 32;
  462. SDL_RenderCopy(pRenderer, m_pCtrlTex->texture, &tS, &tD);
  463. tS.x = 6; tS.y = 0;
  464. tS.w = 6; tS.h = 40;
  465. tD.x = (z << 1) + 6 + 64; tD.w = z;
  466. SDL_RenderCopy(pRenderer, m_pCtrlTex->texture, &tS, &tD);
  467. tS.x = 110; tS.y = 0;
  468. tS.w = 32; tS.h = 40;
  469. tD.x = (z * 3) + 6 + 64; tD.w = 32;
  470. SDL_RenderCopy(pRenderer, m_pCtrlTex->texture, &tS, &tD);
  471. tS.x = 6; tS.y = 0;
  472. tS.w = 6; tS.h = 40;
  473. tD.x = (z * 3) + 6 + 96; tD.w = z;
  474. SDL_RenderCopy(pRenderer, m_pCtrlTex->texture, &tS, &tD);
  475. tS.x = 280; tS.y = 0;
  476. tS.w = 6; tS.h = 40;
  477. tD.x = (z << 2) + 6 + 96; tD.w = 6;
  478. SDL_RenderCopy(pRenderer, m_pCtrlTex->texture, &tS, &tD);
  479. tS.x = 16; tS.y = 122;
  480. tD.y = tD.h = tD.w = tS.w = tS.h = 13;
  481. tD.x = z;
  482. SDL_RenderCopy(pRenderer, m_pCtrlTex->texture, &tS, &tD);
  483. tD.x = (z << 1) + 32;
  484. SDL_RenderCopy(pRenderer, m_pCtrlTex->texture, &tS, &tD);
  485. tD.x = (z * 3) + 64;
  486. SDL_RenderCopy(pRenderer, m_pCtrlTex->texture, &tS, &tD);
  487. tS.x = 6; tS.y = 137;
  488. tD.h = tD.w = tS.w = tS.h = 35;
  489. tD.x = 6 + (z - 35) >> 1; tD.y = 4;
  490. SDL_RenderCopy(pRenderer, m_pCtrlTex->texture, &tS, &tD);
  491. tS.x = 152; tS.y = 137;
  492. tD.h = tD.w = tS.w = tS.h = 35;
  493. tD.x = 6 + 2 * z + 64 + (z - 35) >> 1; tD.y = 4;
  494. SDL_RenderCopy(pRenderer, m_pCtrlTex->texture, &tS, &tD);
  495. tS.x = 88; tS.y = 137;
  496. tD.w = tS.w = 58; tD.h = tS.h = 35;
  497. tD.x = 6 + 4 * z + 105 + (z - 35) >> 1; tD.y = 4;
  498. SDL_RenderCopy(pRenderer, m_pCtrlTex->texture, &tS, &tD);
  499. tS.x = 51; tS.y = 137;
  500. tD.h = tD.w = tS.w = tS.h = 35;
  501. tD.x = 6 + 6 * z + 192 + (z - 35) >> 1; tD.y = 4;
  502. SDL_RenderCopy(pRenderer, m_pCtrlTex->texture, &tS, &tD);
  503. };
  504. };
  505. };
  506. void sdlFlyHunterWidget::drawAfter(SDL_Renderer* pRenderer) {
  507. };
  508. bool sdlFlyHunterWidget::create(void) {
  509. m_pCtrlTex = m_pGUI->loadTexture((CSTR)"fhctrl.png");
  510. return sdlCoreWidget::create();
  511. };
  512. void tutulik1(void) {
  513. if (mHNT == NULL) return;
  514. mHNT->forceArm();
  515. };
  516. void tutulik2(void) {
  517. if (mHNT == NULL) return;
  518. mHNT->disarm();
  519. };
  520. void tutulik3(void) {
  521. if (mHNT == NULL) return;
  522. mHNT->takeOff();
  523. };
  524. void tutulik4(void) {
  525. if (mHNT == NULL) return;
  526. mHNT->land();
  527. };
  528. void tutulik5(void) {
  529. if (mHNT == NULL) return;
  530. mHNT->reset();
  531. };
  532. static uint8_t basic_mode = 0;
  533. void setBasicMode(void) {
  534. basic_mode = 0;
  535. };
  536. void sdlFlyHunterWidget::attachFlyHunter(objectFlyHunter* ptr) {
  537. if (ptr == NULL) {
  538. m_pFH = NULL;
  539. m_pArmMode->Pushed = NULL;
  540. } else {
  541. m_pFH = ptr;
  542. m_pArmMode->Toggled = &tutulik1;
  543. m_pArmMode->UnToggled = &tutulik2;
  544. m_pTakeOff->Pushed = &tutulik3;
  545. m_pLandNow->Pushed = &tutulik4;
  546. m_pHoldPosition->Pushed = &tutulik5;
  547. };
  548. };
  549. void sdlFlyHunterWidget::attachOSD(sdlOsdVideoWidget* ptr) {
  550. if (ptr == NULL) {
  551. m_pOSD = NULL;
  552. } else {
  553. m_pOSD = ptr;
  554. };
  555. };