PolycodeFontEditor.cpp 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. #include "PolycodeFontEditor.h"
  2. PolycodeFontEditor::PolycodeFontEditor() : PolycodeEditor(true){
  3. }
  4. PolycodeFontEditor::~PolycodeFontEditor() {
  5. }
  6. bool PolycodeFontEditor::openFile(String filePath) {
  7. CoreServices::getInstance()->getFontManager()->registerFont(filePath, filePath);
  8. grid = new ScreenImage("editorGrid.png");
  9. addChild(grid);
  10. grid->snapToPixels = true;
  11. grid->getTexture()->clamp = false;
  12. grid->getTexture()->recreateFromImageData();
  13. // bg = new ScreenShape(ScreenShape::SHAPE_RECT, 10,10);
  14. bg = new UIBox("fontBox.png", 29,9,9,9, 10,10);
  15. bg->setPositionMode(ScreenEntity::POSITION_TOPLEFT);
  16. bg->setPosition(-50,-50);
  17. anchor = new ScreenEntity();
  18. addChild(anchor);
  19. anchor->addChild(bg);
  20. anchor->snapToPixels = true;
  21. editorLabel = new ScreenLabel(L"ABCDEFGHIJKLM", 48, filePath, Label::ANTIALIAS_FULL);
  22. anchor->addChild(editorLabel);
  23. editorLabel2 = new ScreenLabel(L"NOPQRSTUVWXYZ", 48, filePath, Label::ANTIALIAS_FULL);
  24. editorLabel2->setPosition(0, 48);
  25. editorLabel->setPosition((editorLabel2->getWidth()-editorLabel->getWidth())/2, 0);
  26. anchor->addChild(editorLabel2);
  27. editorLabel3 = new ScreenLabel(L"abcdefghijklm", 48, filePath, Label::ANTIALIAS_FULL);
  28. editorLabel3->setPosition((editorLabel2->getWidth()-editorLabel3->getWidth())/2, 96);
  29. anchor->addChild(editorLabel3);
  30. editorLabel4 = new ScreenLabel(L"nopqrstuvwxyz", 48, filePath, Label::ANTIALIAS_FULL);
  31. editorLabel4->setPosition((editorLabel2->getWidth()-editorLabel4->getWidth())/2, 144);
  32. anchor->addChild(editorLabel4);
  33. editorLabel5 = new ScreenLabel(L"1234567890", 48, filePath, Label::ANTIALIAS_FULL);
  34. editorLabel5->setPosition((editorLabel2->getWidth()-editorLabel5->getWidth())/2, 192);
  35. anchor->addChild(editorLabel5);
  36. editorLabel->setColor(0,0,0,1);
  37. editorLabel2->setColor(0,0,0,1);
  38. editorLabel3->setColor(0,0,0,1);
  39. editorLabel4->setColor(0,0,0,1);
  40. editorLabel5->setColor(0,0,0,1);
  41. bg->resizeBox(editorLabel2->getWidth()+100, 192+48+100);
  42. anchor->setHeight(192+48);
  43. anchor->setWidth(editorLabel2->getWidth());
  44. PolycodeEditor::openFile(filePath);
  45. return true;
  46. }
  47. void PolycodeFontEditor::Resize(int x, int y) {
  48. anchor->setPosition((x-anchor->getWidth()) /2, (y-anchor->getHeight()) /2);
  49. grid->setImageCoordinates(0,0,x,y);
  50. }