-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SkillListActivity: generate skill card images instead of using scans #9
Comments
Looking into this for issue #22, the card scans are a hair over 90% of the APK's size. That's ridiculous. |
OTOH, it's only ridiculous because of the 100M Play Store limit. |
Let the record reflect that Stephan has volunteered to enter all card data. |
That's an unsubstantiated rumor intended to sow... oh, wait. Indeed, i did. i'll have my people call your people. |
Okay, my people called and said that we have one slight problem they need your people to agree on before this goes too far... Within the text of skills/masteries, we sometimes see glyphs, e.g.: "If you pass & the GP {GLYPH} cost of the Item..." Your people are going to want to include the intended glyphs, rather than just the words. To that end, my people suggest a common notation for the glyphs, e.g. {:GP:} or {:WOUND:} or some such. My people, however, are not emotionally invested in any one solution, so they'll leave that up to your people to decide. The traits denoting when a skill can be used don't have the same problem because they're standalone - they aren't embedded in free-form text. e.g. Alchemy has the "town" trait, which can simply be noted as "town" or "Town" or hashtag "#town", without requiring any weird markup. There are cases where we'll need to denote either/or, and my people suggest using a double-pipe for that for the time being, with multiple traits on either side of the pipe being ANDed with each other, effectively treating At your earliest convenience, please have your people let my people know how your people would like that handled. |
Hmmm. It seems that some cards use mixed normal/italics fonts. Do we care or do we want to use, e.g., markdown notation for those? Draw a card from the Loot deck. If it is an Ally, Item, or Service, you may purchase it for the normal cost (otherwise discard it). |
Also... i'm just now seeing typos i've never noticed (e.g. Bleeding). Do we retain them or fix them? (Edit: no wonder i haven't noticed the Bleeding typo before - Mean Streets hasn't yet arrived in the EU. It's due to start fulfillment from the UK today, so it "should" be here by Wednesday/Thursday of next week.) |
Milestone - the list of skills has been transcribed. There's certain card-specific metadata which still has to be hashed out, but the text is all captured in a spreadsheet. The Masteries are next (but probably not today) and then the Danger Cards. There are apparently a whopping 60 skills. Who knew? |
My People have called to inform yours that both the Skill and Mastery lists are now transcribed. The skill list, as seen in the screenshot above, had to be reworked to include the traits in the skill markup, instead of a separate piece of card-level metadata, because many skills/masteries use multiple paragraphs, each with their own trait(s) (though the traits are often identical for 2 paragraphs, which is kind of weird, but that's what we have). i have been able to capture almost all of the formatting patterns within the markup/text structure (sometimes it's implicit, e.g. a block starting with a stance will have background color Y, where Y is dependent on the card's background color), but there are a couple outliers where there is no apparent rhyme or reason as to why a given paragraph is a different color from the one before it. That can all be cleaned up at our leisure, now that the content of each has been captured. We can, e.g. break each paragraph into a separate JSON object and add any traits as a property of that object, rather than in markup. For some cases that separation would be problematic, though: an example is an attribute bonus, which can appear either at the end or beginning of given paragraph of skill text, but is always styled one particular way (distinct from the paragraph's color). |
While transcribing the Danger cards, it just occurred to me that it would be hilarious to add support for Google's text-to-speech to read them. (In your best Google Assistant voice: "Cults of death practice necromantic rites & dead things hunt the living who dare enter THE CATACOMBS") |
My People have just informed me that the transcription of the Danger cards is done, but that one (Highlands Outbreak) has a universe-breaking bug which i was forced to fix: https://www.boardgamegeek.com/thread/2224679/ Is there really no Badlands Outbreak card? Are they immune to the plague? So... we've now got all Skills, Masteries, and Danger cards in a gdocs spreadsheet, the link to which i don't yet want to post in a public forum. From there we can easily [enough] restructure it as JSON or TIFF or VCAL or whatever the cool kids are using nowadays. Seriously, though: think about adding text-to-speech for the danger card flavor text. That would be a hoot. Edit: i just tried it via one of the copy/paste TTS websites and it is indeed funny. In its own way. Not very thematic, though. |
Holy cow, excellent, except for the part about NOW I HAVE TO WRITE THE CODE. (Hopefully this didn't set back your recovery!)
Well, the Badlands are so awful that, if a location does have plague, who can tell? By the way, it is great + hilarious to be coding with you again. What were the odds?? |
One complication here is that, although we're including the font which contains Dungeon Degenerates glyphs ( We may wind up using |
i admit that such complications didn't occur to me at the time... but now they'll haunt my dreams like a badly-painted mini (that was actually last night's dream). The web view doesn't sound like a half-bad idea. Or is it... dare i say it... a morbad idea? One major benefit of that is that it would, IMO, be easier to control the text size. Some cards need smaller fonts because they are verbose. A simple css tweak would be all that's needed, rather than you writing code to calculate text sizes, word-wrapping, etc. We also have all of the individual glyphs in SVG format (i'll drop you a link to that), so we could embed those as image tags. |
With the webview: perhaps... just perhaps... the card-rendering/HTML-generating code could be implemented in JavaScript, taking the card data from a JSON object. That's something which could easily be developed outside of the app, which should simplify the dev process greatly. It would also allow us, Goblinko permitting, to host an online card db using the same code (perhaps a web-based variant of this app). Hmmmm... i'm now more than half tempted to give that a go. First i'd need to convert the spreadsheets to JSON. Parsing the markup from JS also wouldn't be all that difficult, eliminating the need to write Java code for that. Here's a video which allegedly demonstrates how to turn on JS for the webview (JS is off by default): https://www.youtube.com/watch?v=H8N7H6dlMCE i don't know if there are any limitations in that sandbox which might bite us, though. |
i'm looking at converting the spreadsheet data to json. For the skill cards that's pretty straightforward except for one question: when a card has multiple paragraphs of text, do we want those all stored together as one string (with markup denoting the paragraph breaks (noting that there are 2 different kinds of paragraph breaks on the cards)) or as an array of paragraph objects which contain the string and any metadata (e.g. color and paragraph break type)? If we do the latter, we could move some of the markup, e.g. |
I'm leaning toward one string. Two things to test:
|
For point 1 i figured we can say "if strlen<X, use font size 1em, else if strlen<Y, use 0.8em..." etc. i suspect that would work out well enough. With JS we can dynamically (and easily) adjust the DOM element style properties. i assume webview supports svg, since all modern browsers do, but haven't researched it. |
Looks like the default behavior is to add scrollbars and draw beyond the fixed size. Now, that's not necessarily bad... in fact, it's arguably good. My intent was to have code which would render Skill cards as closely as possible to the printed cards, but... since we don't have to constrain ourselves to a fixed-size cardboard rectangle, maybe we don't want to? Would that be weird to have the text on all "cards" be the same easy-to-read size, and have to scroll to see everything on cards with lengthy text? |
Maybe it's an option in Settings, ha ha. |
i am ambivalent. Let's see how it goes both ways. The scroll approach requires no code but the other approach theoretically requires 5 minutes of coding, so it's tomato/tomahto. (OTOH, we all know how "theoretically" rends to work out in practice.) i will be tied up with other stuff until Thursday (and my DD KS should arrive Tuesday or Wednesday) but will then take a serious look at converting the card data to json and implementing a renderer in JS. |
Looks like it does; I've got it displaying your dd-glyphs.svg as a test. (I wasn't sure because googling "android webview svg" gave some... disturbing results.) |
i didn't think to ask whether JS is on your list of Core Competencies. We don't have to use JS if you don't want to, it just seems like an easy way to simplify development for this case (i'm right at home with JS, despite its annoying quirks). The whole rendering process could be developed outside of the app and reused in a web app. |
JS is not my favorite, but I have done stuff with it; I just can't let anyone watch me write it, because I can't get anything done without documentation open in another window. But if you're writing it, it's fine with me! |
For later reference: it seems we can determine if a scrollbar is visible, which is info we can use to keep shrinking the font until the scrollbar goes away: https://stackoverflow.com/questions/4814398/how-can-i-check-if-a-scrollbar-is-visible The relevant bit is |
One other fun thing about using JS instead of SVG is it makes it a little easier to support other languages. (Only a little bit; I mean, we can support language-specific SVGs about as easily as supporting language-specific card text+markup strings.) Because the game is so heavy on English text, I wouldn't have thought this would be useful, but if someone's got a site where entering native language translations will give them a set of native language cards they can print for their copy of the game... |
Hey, I'm sorry; I'm still unclear on how to actually use the JS. If I add a function
but what function in (In the |
Man, you're asking difficult questions. As my first programming mentor used to say (on the topic of documenting software):
Actually... i have to go check.
Definitely not. That file is best considered "upstream code". i'd be glad to do a Google Hangout session to help you get it running (i have... somewhere... a Skype account, and could dig that out if preferred). i'll go through Ideally you'll just need to:
From webview:
|
PS: i'm putting together a stub bit intended for this use as the glue. i'll post back when it's done. |
I did that bit (including an alternate version of
That's where things go wrong; I lack the JavaScript chops to figure out what I need to do from looking at |
i'm about 80% done with your stub file. Just need to remove some older crufy from the overblown demo, then we'll be set. JSON dialect: do you have your own are are we going to use Looking at your |
If I can pass in the various elements (name, text+markup, XP cost, copyright flag, etc.) as individual arguments, that's best, but if I need to assemble those into a single JSON object in the expected format, that's fine too.
My hope is that, for each skill, I can copy the skill text+markup, mastery text+markup, and optional copyright flag (and anything else I'm forgetting) into the existing |
The JS API can't currently handle them piecemeal - it eats only healthy, whole-wheat JSON objects. i'll add "split up card processor" to the TODO list.
That would also be fine. If you use a different structure, we'll need one more tiny JS function to translate the structure, but that's trivial.
There's no reason in the world you can't. The JS-side copy is currently one big bundle, for simplicity (and because the spreadsheet-to-JS converter doesn't have enough information to split them), but if you're passing the JSON from Java then it's entirely your business how it's split up. Long live The StubThe app stub is "done" (for a given definition of done). Please check the gdrive for:
i think that this provides everything the Java world needs. |
Goodness, no, I went with MorbadScorepad. :P |
Just to confirm: i just ran both of our jsons through a script and they share identical IDs. However, your
|
(Yeah, Android Studio complains about them too; I strip them out before passing them on to Gson or whatever.) |
i've made that typo no less than 8 times today :/. |
If you would, please updated to the latest Also, just fyi, in case this is something you're into: i just found that if you run that JS through a minifier, it will shrink to <20k. Edit: use |
i need an opinion... if i move that damned dangling "XP Val" widget out of the way, i can get much tighter automated font-size fits: Is that evil of me? The problem is that accounting for that widget is essentially impossible because we don't know how large of a gap lies between the bottom of the last line of text and the bottom of the skill text area. When calculating the font size (which i've just sped up a great deal, but am still testing), we're left guessing how much of a gap we're leaving at the end of the card body. Moving that widget to the top, where it will never overlap anything, eliminates that problem, but of course has the problem of "potential cognitive dissonance". |
Oh, man, that's a tough call; it really does fit better up by the "Skill" string. I was going to say maybe you could leave it down at the bottom and just assume the bottom bit of the card was unusable, but I see the original Find Weakness wraps around the XP area. (Same with Levitate.) In figuring out how much space you have, can you assume a fixed width for the XP area, and that only one line will have to wrap around the XP area? So, with 10 lines, your total available space is 9 * card width + last-line-width; with 11 lines, your total available space is 10 * card width + last-line-width, etc.? |
OK, I've got it displaying just the Skill card in one WebView, and just the Mastery card in the other WebView, and I've got them updating when a new skill is selected (using complete JSON passed in); the only thing I need to goof with is the scale (they don't fit in the available space, and although you can scroll around, you can't zoom in/out). I assume I can fix that by messing with stuff in the HTML or CSS. |
It's a non-issue now. i came up with some tricks which now allows it to work Pretty Damned Well (a tighter fit than before), despite that XP Val widget (and just copied that to the gdrive). In short... As before, the algorithm basically works like this: set a massive font size and check for overflow. If it's not overflowing, great. If it is, reduce the font size one step and try again. One "step" means trying the next-lower With that in mind, the changes are...
Here's a very interesting case which demonstrates how the XP val thingie is a problem: Note the ostensibly large gap at the bottom of the Skill. i double-checked that by hand and it's actually doing exactly the right thing: if we increase the font size by 1 step (0.6pt) then it gets pushed down 1 line, which overlaps the top of the XP widget by a fraction of a hair. The text does not actually overlap because it's only 1 word, but we can't know that at this level - we can only see how far down the text goes. So the algo, at the end, says, "you're overlapping - back up one font step, please." (Except that it doesn't say please.) Anyway... this would have been tons easier (like 10+ hours easier) if that damned XP val widget wasn't a potential overlap risk. The up-side to that time sink was that i learned a couple new JS tricks, namely... For posterity's sake, since i can't just link to my private repo from here until i get permission from goblinko, he are Steve's New Tricks:
|
Try adding this CSS to each card:
If needed, we can add a JS function which takes a number from java, and scales them appropriately. |
Also: why two? It seems like it would be easier to just display both in the same webview. |
In the off chance that you have already updated |
It gets worse... while creating a new repo for the pending public release (shorn of the skill database), i accidentally typed...
:-/ i shall accept my punishment with grace. |
Minor forewarning: i'm re-orging and renaming the files for the upcoming public repo and the CSS file will be restructured/renamed:
The intentions of this reorg is basically (A) to move everything out of the top-most directory, (B) simplify updates to client apps (several are in the works, and they should just have to update/replace this whole dir for new versions), and (C) standardize how the sources/CSS files are included from client code and how the URIs for the icons and dynamically-loaded CSS files are used within the library code (because they are relative to the including HTML file, not the being-executed JS file). |
Aaaaallllllrightythen.... My "migration" is complete and i've now got a public repo without any of Goblinko's copyrighted data in it (except the glyphs, for which we have a license): https://fossil.wanderinghorse.net/r/morbad-card-tools/ There are at least 2 options for you, in terms of keeping up to date with the code:
The Code is in the |
One funny thing about using SVGs instead of rendering the cards in JS is that it probably means we could use the real Dominican font (issue #7). Its license says it's free to use; you just can't distribute the font itself. But if you use the font to generate an SVG which converts the letters to paths, you're not distributing the font... (I do prefer to stick with the JS, though, because I think it gives us some flexibility; we could give the user some control over how we render the cards at runtime.) |
Apropos fonts... i played around today with swapping out fonts, just to see if the font size calculation could deal with it. That part worked great, but the rest of the card (headers, "REQ", req. list) were all mangled. Our font is "unusually small". That is, its 12pt is smaller than an average 12pt. Swapping fonts will require, at the least, that we include, for each font, CSS overrides which set the font size for those UI elements. Alternately, we dynamically recalc the font for every widget on the card. Unfortunately, the recalc algorithm is very dependent on the structure of |
I have the latest version from fossil, but it breaks the earlier |
Doh - that was renamed and i think i added an optional parameter to it. i'll look at that in the next hour or so and get you a new demo app. About the timing kludge thing: the font calculation cannot work until the element is in the DOM. Even then, depending on whether the DOM is updated with the element's current state or whether it's waiting on JS to stop processing so the DOM can update, the font calculation may or may not be complete. The "force update" is just a second pass, once the card is in full view. That font update is not needed at all if the cards are outfitted with known-working i'll be in touch in the next hour or so with a modernized demo page. |
Done with both tasks. i'll send it via email in a few minutes. |
Using scanned skill cards is dumb; it would be better if each skill had the text of its effects (plus some markup to indicate which bits were effects/actions you could use during Rest, or in Assault or Guard stance--the stuff on p. 11 of the rules), and then we render card images accordingly at runtime. (Like, the Immunity skill is two sentences; it's grossly inefficient to have four differently-scaled photos of the card.) However, that means someone will have to write the code to do that. (It would be interesting code...)
The text was updated successfully, but these errors were encountered: