Skip to content

Instantly share code, notes, and snippets.

@Mehuge
Last active August 29, 2015 14:28
Show Gist options
  • Save Mehuge/750abc028531835aa238 to your computer and use it in GitHub Desktop.
Save Mehuge/750abc028531835aa238 to your computer and use it in GitHub Desktop.
"imports": {
"resources": [
/* all unitframe related resources from the cu-components module */
{ resource: "cu-components/unitframe/images", dest: "images/unitframe" },
{ resource: "cu-components/unitframe/styles", dest: "styles" },
/* just the portrait resources required */
{ resource: "cu-components/unitframe/portrait/images", dest: "images/unitframe/portrait" }
]
}
"resources": {
"$base": "lib/classes",
"unitframe": {
"images": [ "lib/classes/unitframe/images/*.png" ],
"styles": [ "lib/classes/unitframe.css" ],
"portrait": {
"images": [ "lib/classes/unitframe/images/portrait/*.png" ],
"styles": [ "lib/classes/unitframe/portrait.css"]
},
"$refs": [ "shared "]
}
}
@Mehuge
Copy link
Author

Mehuge commented Aug 25, 2015

Lets look at an example of a stock Target UI that wants to use the UnitFrame class of the cu-components library which defines a bunch of images resources that the stock UI uses.

In this case, the build will want to copy the resources into the build output. I accept that these should be in a shared location, so that multiple UIs using the same resources, the Target UI is a good example, as it shares resources with the friendly target UI and character UI.

So we need to be able to tell the build config to output these resources to a shared location rather than bundle them with each specific UI.

So, making an assumption that, the build output of cu-ui-v2 will be ./dist/... then building the three unit frame UIs should result in something like this:-

dist/images/unitframe/....png // frame art images
dist/images/unitframe/portrait/....jpg // portrait images (used by character UI only)
dist/styles/unitframe.css
dist/character/index.html
dist/character/main.js
dist/character.ui
dist/enemytarget/index.html
dist/enemytarget/main.js
dist/enemytarget.ui
dist/friendlytarget/index.html
dist/friendlytarget/main.js
dist/friendlytarget.ui

Yes, there is some duplication of copying of resources, as each of the character/enemy/friendly target UIs is built, but they all output to the same location, so the only duplication is in build not in the result.

@Mehuge
Copy link
Author

Mehuge commented Aug 25, 2015

But wait, there's more...

Sounds like what @csejb has in mind is that we won't need a separate copy resources stage for stock UIs because all the libraries resources will be included in a cu-components folder and the resources will be referenced directly from there.

@jcdickinson
Copy link

"resources": {
  "$base": "lib/classes",
  "$sym": {
    "$lib": "../../../client/assets/webui/lib",
    "$cuui": "../../../client/assets/webui/cu-ui"
  },
  "unitframe": {
    "images": [ "lib/classes/unitframe/images/*.png", "$cuui/classes/unitframe/images/border.png" ],
    "styles": [ "lib/classes/unitframe.css" ],
    "portrait": {
      "images": [ "lib/classes/unitframe/images/portrait/*.png" ],
      "styles": [ "lib/classes/unitframe/portrait.css"]
    },
    "$refs": [ "shared "]
  }
}

@Mehuge
Copy link
Author

Mehuge commented Aug 25, 2015

I think after the chat with csejb we just had, I think this whole gist is obsolete!!

Stock UIs won't need to copy resources, they will simply reference them from lib//...

Custom UIs can either reference the stock resources lib//... in the same way or provide their own.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment