Project [email protected] 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. /******************************************************************************/
  2. #include "stdafx.h"
  3. /******************************************************************************/
  4. ProjectUpdate ProjUpdate;
  5. State StateProjectUpdate(UpdateProjectUpdate, DrawProjectUpdate, InitProjectUpdate, ShutProjectUpdate);
  6. /******************************************************************************/
  7. bool InitProjectUpdate()
  8. {
  9. SetKbExclusive();
  10. Proj.pause(); // pause first
  11. UpdateProgress.create(Rect_C(0, -0.05f, 1, 0.045f));
  12. ProjUpdate.start(Proj, WorkerThreads); // start at the end
  13. return true;
  14. }
  15. void ShutProjectUpdate()
  16. {
  17. ProjUpdate.stop(WorkerThreads); // stop first
  18. UpdateProgress.del();
  19. Proj.refresh().resume(); // resume at the end
  20. WindowSetNormal();
  21. WindowFlash();
  22. }
  23. /******************************************************************************/
  24. bool UpdateProjectUpdate()
  25. {
  26. if(Kb.bp(KB_ESC)){StateProjectList.set(StateFadeTime); Gui.msgBox(S, "Updating Project breaked on user request");}
  27. if(!WorkerThreads.busy())
  28. {
  29. if(Proj.needUpdate()) // if after updating, the project still needs an update, then it means that some error must have occured
  30. {
  31. Proj.close();
  32. Gui.msgBox(S, "Project did not update completely");
  33. }
  34. SetProjectState();
  35. }
  36. UpdateProgress.set(ProjUpdate.texs.elms()-WorkerThreads.queued(), ProjUpdate.texs.elms());
  37. WindowSetProgress(UpdateProgress());
  38. Time.wait(1000/30);
  39. //Gui.update(); this may cause conflicts with 'Proj.elmChanged'
  40. Server.update(null, true);
  41. if(Ms.bp(3))WindowToggle();
  42. return true;
  43. }
  44. /******************************************************************************/
  45. void DrawProjectUpdate()
  46. {
  47. D.clear(BackgroundColor());
  48. D.text(0, 0.05f, "Updating Project");
  49. GuiPC gpc;
  50. gpc.visible=gpc.enabled=true;
  51. gpc.client_rect=gpc.clip.set(-D.w(), -D.h(), D.w(), D.h());
  52. gpc.offset.zero();
  53. UpdateProgress.draw(gpc);
  54. D.clip();
  55. }
  56. /******************************************************************************/
  57. /******************************************************************************/