Fantasy-Map-Generator icon indicating copy to clipboard operation
Fantasy-Map-Generator copied to clipboard

FMG 2.0: Codebase refactoring and modernization

Open Azgaar opened this issue 2 years ago • 11 comments

Description

Starting working on a major code refactoring and modernization.

Goals:

  • full code decoupling using es6 modules
  • removing most of global variables / functions
  • codebase modernization
  • full Typescript support
  • production code minification
  • save data format change: https://trello.com/c/IWltiMC2/902-rework-save-data-format
  • model / view separation: https://trello.com/c/u7ip0bgD/786-separate-view-from-model
  • remove jQuery dependency, to do this need to come up with a custom solution for Dialogs (e.g. Web Component)
  • reducing dependency on d3, using d3 only when needed

Contract changes as of today

Regiments:

  • state.military is renamed to state.regiments
  • regiments contract is reworked

Routes:

  • pack.cells.road is renamed to pack.cells.route
  • pack.cells.route values are repurposed, now 1 means road, 2 - trail, 3 - seaRoute
  • pack.routes now stores all relevant routes data

Diplomacy:

  • Ongoing wars are not longer stored in pack.states[0].diplomacy
  • Historical campaigns are not longer stored in pack.states[x].campaigns => Both are now stored as an array in pack.events.conflicts

Provinces:

  • pack.states[x].provinces is removed. Now states don't store info about their provinces

Labels:

  • text-anchor for '#labels' element is changed from 'start' to middle. All child tspan elements now should have attribute x equal to 0 instead of a calculated value

Type of change

  • [x] Other (architecture change)

Versioning

  • [ ] Version is updated
  • [ ] Changed files hash is updated

Azgaar avatar Jun 24 '22 21:06 Azgaar

Wow, wow, wow... that's quite a change. :-O I already did some of these changes (very small subset of it) I have to catch up now.

Vite seems to be a cool stuff, but is it strictly necessary?

netlify[bot] @.***> ezt írta (időpont: 2022. jún. 24., Pén 23:52):

✅ Deploy Preview for afmg ready! Name Link 🔨 Latest commit bc65e0e https://github.com/Azgaar/Fantasy-Map-Generator/commit/bc65e0e20719635e96046fd6ee6e2399e0697a04 🔍 Latest deploy log https://app.netlify.com/sites/afmg/deploys/62b631e6bac4b00008014869 😎 Deploy Preview https://deploy-preview-842--afmg.netlify.app/ 📱 Preview on mobile Toggle QR Code...

[image: QR Code] https://camo.githubusercontent.com/f155e98a26559c5d656155bccf0b95a26b92fa57ab0ac1758c9ddd0df6866bff/68747470733a2f2f6170702e6e65746c6966792e636f6d2f71722d636f64652f65794a30655841694f694a4b563151694c434a68624763694f694a49557a49314e694a392e65794a31636d77694f694a6f64485277637a6f764c32526c6347787665533177636d5632615756334c5467304d69307459575a745a7935755a58527361575a354c6d467763434a392e68706e4b7a565331456d77673633695655615f58343165695f714142655666696a5a43696e765153306c38

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings https://app.netlify.com/sites/afmg/settings/deploys#deploy-notifications.

— Reply to this email directly, view it on GitHub https://github.com/Azgaar/Fantasy-Map-Generator/pull/842#issuecomment-1165968486, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAUMDVNIHDP4V4UD3JQOXVTVQYUYBANCNFSM5ZZCTPXA . You are receiving this because you are subscribed to this thread.Message ID: @.***>

goteguru avatar Jun 26 '22 04:06 goteguru

It's not necessary at all. But that is one-time action that will allow a lot of cool things in the future. It also forces to write a better code and think a lot about the structure

Azgaar avatar Jun 26 '22 09:06 Azgaar

This change is really welcome! Thanks for your hard work, that must be painful.

I'm interested in vite's on demand refresh feature. How can I kick in easily ? (Which template to use if any, are there any pitalls to avoid?)

Azgaar @.***> ezt írta (időpont: 2022. jún. 26., Vas 11:12):

It's not necessary at all. But that is one-time action that will allow a lot of cool things in the future. It also forces to write a better code and think a lot about the structure

— Reply to this email directly, view it on GitHub https://github.com/Azgaar/Fantasy-Map-Generator/pull/842#issuecomment-1166463345, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAUMDVONUGBMHYIPMYBWTWDVRANJJANCNFSM5ZZCTPXA . You are receiving this because you commented.Message ID: @.***>

goteguru avatar Jun 26 '22 09:06 goteguru

Do you mean hot module replacement? If so, it works just fine out of the box.

The template I used is a very basic vanilla-js + typescript: https://stackblitz.com/edit/vitejs-vite-epqe9h?file=index.html&terminal=dev

Azgaar avatar Jun 26 '22 09:06 Azgaar

Yes, that one.

Azgaar @.***> ezt írta (időpont: 2022. jún. 26., Vas 11:53):

Do you mean hot module replacement? If so, it works just fine out of the box.

The template I used is a very basic vanilla-js + typescript: https://stackblitz.com/edit/vitejs-vite-epqe9h?file=index.html&terminal=dev

— Reply to this email directly, view it on GitHub https://github.com/Azgaar/Fantasy-Map-Generator/pull/842#issuecomment-1166475264, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAUMDVJZFY2KYZXJNVCCEJ3VRASCBANCNFSM5ZZCTPXA . You are receiving this because you commented.Message ID: @.***>

goteguru avatar Jun 26 '22 10:06 goteguru

Is it largely finished? Can I test and use this branch?

goteguru avatar Jun 27 '22 13:06 goteguru

Nope, it's very far from completion. It's not yet working and also probably I'm introducing ton of bugs.

Azgaar avatar Jun 27 '22 18:06 Azgaar

Since we've discussed it in #902 I thought I'd ask, is there some way we can help with this migration work?

Minivera avatar Dec 15 '22 16:12 Minivera

Since we've discussed it in #902 I thought I'd ask, is there some way we can help with this migration work?

Yes, the UI part if not refactored at all. There are multiple elements to work on.

Azgaar avatar Dec 15 '22 16:12 Azgaar

With regards to human readable remark - I don't see how a human readable format could be structured. BUT, SVG supports metadata which means that maps could be exported as a simplified rendered SVG with current JSON stored in minified format as embedded data.

Benefit of doing that would be that saved maps would have proper thumbnails on certain OSs and could be previewed so the user knows a general layout of the map they're about to open.

Caellian avatar Oct 30 '23 09:10 Caellian

With regards to human readable remark - I don't see how a human readable format could be structured. BUT, SVG supports metadata which means that maps could be exported as a simplified rendered SVG with current JSON stored in minified format as embedded data.

Benefit of doing that would be that saved maps would have proper thumbnails on certain OSs and could be previewed so the user knows a general layout of the map they're about to open.

There is no intention to store map data in svg. SVG can stay for a while, but the ultimate goal is to separate data from view, so the .map file can be even potentially rendered in other systems outside of FMG.

Azgaar avatar Oct 30 '23 11:10 Azgaar