common.js 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. import { defineStore } from 'pinia'
  2. import paper from 'paper';
  3. export const CommonStore = defineStore({
  4. id: 'common',
  5. state: () => ({
  6. hover_elmt: null,
  7. map_item_ray: Math.min(window.innerWidth, window.innerHeight) * 0.08,
  8. original_cartouch_width: 450,
  9. cartouch_width: 450,
  10. cartouch_is_opened: false,
  11. paper_symbol_definitions: {}
  12. }),
  13. getters: {
  14. },
  15. actions: {
  16. setHoverElmt(elmt) {
  17. // console.log(`setHoverElmt`, elmt);
  18. // mode can be : terraindevie, proximite, superposition, puissancedagir, action, doleancer
  19. this.hover_elmt = elmt;
  20. },
  21. setCartoucheWidth (delta) {
  22. console.log('CommonStore setCartoucheWidth', delta);
  23. this.cartouch_width = this.original_cartouch_width * delta;
  24. },
  25. setCartoucheOpened (v) {
  26. console.log('setCartoucheOpened', v);
  27. this.cartouch_is_opened = v;
  28. },
  29. addPaperSymbolDefinition(name, path) {
  30. // console.log(`addPaperSymbolDefinition ${name}`, path);
  31. // mode can be : terraindevie, proximite, superposition, puissancedagir, action, doleancer
  32. this.paper_symbol_definitions[name] = new paper.SymbolDefinition(path);
  33. }
  34. }
  35. })