Advertisement
Zgragselus

Untitled

Oct 14th, 2023
837
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.00 KB | None | 0 0
  1. mMenuUI->AddMenu("File");
  2. mMenuUI->AddMenuItem(0, "Open",
  3.     [&]() -> void
  4.     {
  5.         std::string filename;
  6.         bool open = Engine::FileDialog::Show(mSctex->mLog, "Open Image", "Image Files\0*.jpg;*.jpeg;*.png;*.bmp;*.tga;*.dds;*.tif;*.gif;*.sctex\0All Files\0*.*\0", Engine::FileDialog::Type::OPEN_FILE_DIALOG, filename);
  7.         if (open)
  8.         {
  9.             mSctex->mTextureFilename = filename;
  10.             mSctex->mLoadTexture = true;
  11.  
  12.             // Reset miplevel, view and exposure when loading a new image
  13.             mSctex->mCurrentMiplevel = 0.0f;
  14.             mSctex->mTransform = Engine::mat3();
  15.             mSctex->mExposure = 1.0f;
  16.         }
  17.     });
  18. mMenuUI->AddMenuItem(0, "Save",
  19.     [&]() -> void
  20.     {
  21.         std::string filename;
  22.         bool save = Engine::FileDialog::Show(mSctex->mLog, "Save Compressed Image", "Skye Cuillin Texture\0*.sctex\0All Files\0*.*\0", Engine::FileDialog::Type::SAVE_FILE_DIALOG, filename);
  23.         if (save)
  24.         {
  25.             Engine::LoaderSctex* sctexLoader = new Engine::LoaderSctex(mSctex->mLog);
  26.  
  27.             std::vector<Engine::LoaderSctex::Image> data;
  28.  
  29.             for (size_t i = 0; i < mSctex->mCompressedLevels; i++)
  30.             {
  31.                 Engine::LoaderSctex::Image image;
  32.                 image.mWidth = mSctex->mCompressedWidth[i];
  33.                 image.mHeight = mSctex->mCompressedHeight[i];
  34.                 image.mData = mSctex->mCompressedData[i];
  35.  
  36.                 data.push_back(image);
  37.             }
  38.  
  39.             sctexLoader->Save(filename, mSctex->mCompressedFormat, data);
  40.  
  41.             delete sctexLoader;
  42.         }
  43.     });
  44. mMenuUI->AddMenuItem(0, "Exit",
  45.     [&]() -> void
  46.     {
  47.         Engine::EventChannel chan(mEventSystem);
  48.         chan.Broadcast(Engine::Scheduler::StopEvent());
  49.     });
  50. mMenuUI->AddMenu("Edit");
  51. mMenuUI->AddMenuItem(1, "Compress", [&]() -> void { mCompressDialogUI->Show(); });
  52. mMenuUI->AddMenu("View");
  53. mMenuUI->AddMenuItem(2, "Mip Level Up", [&]() -> void { mSctex->MipLevelUp(); });
  54. mMenuUI->AddMenuItem(2, "Mip Level Down", [&]() -> void { mSctex->MipLevelDown(); });
  55. mMenuUI->AddMenuItem(2, "Reset View", [&]() -> void { mSctex->mTransform = Engine::mat3(); });
  56. mMenuUI->AddMenuItem(2, "Reset Exposure", [&]() -> void { mSctex->mExposure = 1.0f; });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement