uv.cpp 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. #ifndef _XBOX
  2. #include "uv.h"
  3. #include "..\..\system\datasource\datauv.h"
  4. extern IGUIManager* Application;
  5. UVEditor::UVEditor ()
  6. {
  7. TSelectorForm = NULL;
  8. EditedUV = NULL;
  9. }
  10. UVEditor::~UVEditor ()
  11. {
  12. }
  13. void UVEditor::Release ()
  14. {
  15. delete this;
  16. }
  17. void UVEditor::BeginEdit (GUIControl* form, DataUV* EditedUV)
  18. {
  19. this->EditedUV = EditedUV;
  20. TSelectorForm = NEW TTextureSelector ();
  21. TSelectorForm->OnClose = (CONTROL_EVENT)&UVEditor::CloseForm;
  22. DWORD FramesCount = EditedUV->GetFrameCount();
  23. for (DWORD n = 0; n < FramesCount; n++)
  24. {
  25. Vector4 Frame = EditedUV->GetValue(n);
  26. TSelectorForm->AddFrame(Frame.x, Frame.y, Frame.z-Frame.x, Frame.w-Frame.y);
  27. }
  28. Application->ShowModal(TSelectorForm);
  29. }
  30. void UVEditor::EndEdit ()
  31. {
  32. TSelectorForm = NULL;
  33. }
  34. void UVEditor::Apply ()
  35. {
  36. }
  37. void _cdecl UVEditor::CloseForm (GUIControl* sender)
  38. {
  39. int FrameCount = TSelectorForm->GetFrameCount();
  40. Vector4* FramesArray = NEW Vector4[FrameCount];
  41. for (int n = 0; n < FrameCount; n++)
  42. {
  43. Vector4 FrameInfo;
  44. TSelectorForm->GetFrame(n, FrameInfo.x, FrameInfo.y, FrameInfo.z, FrameInfo.w);
  45. FramesArray[n].x = FrameInfo.x;
  46. FramesArray[n].y = FrameInfo.y;
  47. FramesArray[n].z = FrameInfo.x + FrameInfo.z;
  48. FramesArray[n].w = FrameInfo.y + FrameInfo.w;
  49. }
  50. EditedUV->SetValues(FramesArray, FrameCount);
  51. delete FramesArray;
  52. }
  53. #endif