-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
568 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
|
||
node_modules/ | ||
|
||
# Logs | ||
logs | ||
*.log | ||
|
||
# Runtime data | ||
pids | ||
*.pid | ||
*.seed | ||
|
||
# Directory for instrumented libs generated by jscoverage/JSCover | ||
lib-cov | ||
|
||
# Coverage directory used by tools like istanbul | ||
coverage | ||
|
||
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) | ||
.grunt | ||
|
||
# Compiled binary addons (http://nodejs.org/api/addons.html) | ||
build/Release | ||
|
||
# Dependency directory | ||
# Commenting this out is preferred by some people, see | ||
# https://www.npmjs.org/doc/misc/npm-faq.html#should-i-check-my-node_modules-folder-into-git- | ||
node_modules | ||
|
||
# Users Environment Variables | ||
.lock-wscript | ||
|
||
# ========================= | ||
# Operating System Files | ||
# ========================= | ||
|
||
# OSX | ||
# ========================= | ||
|
||
.DS_Store | ||
.AppleDouble | ||
.LSOverride | ||
|
||
# Thumbnails | ||
._* | ||
|
||
# Files that might appear on external disk | ||
.Spotlight-V100 | ||
.Trashes | ||
|
||
# Directories potentially created on remote AFP share | ||
.AppleDB | ||
.AppleDesktop | ||
Network Trash Folder | ||
Temporary Items | ||
.apdisk | ||
|
||
# Windows | ||
# ========================= | ||
|
||
# Windows image file caches | ||
Thumbs.db | ||
ehthumbs.db | ||
|
||
# Folder config file | ||
Desktop.ini | ||
|
||
# Recycle Bin used on file shares | ||
$RECYCLE.BIN/ | ||
|
||
# Windows Installer files | ||
*.cab | ||
*.msi | ||
*.msm | ||
*.msp | ||
|
||
# Windows shortcuts | ||
*.lnk |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
|
||
# Card Game Generator | ||
|
||
A tool for developing card games for and along with [Tabletop Simulator][]. | ||
|
||
Use HTML or SVG templates to create and render custom decks of cards | ||
and style them with CSS. | ||
|
||
|
||
## Installation | ||
|
||
* Have [Node.js][] and create a project | ||
* `npm install card-game-generator --save-dev` | ||
|
||
<!-- | ||
## Import into Tabletop Simulator | ||
Without installing, you can save [Card Game.json][] to `%USERPROFILE%\Documents\My Games\Tabletop Simulator\Saves\Chest\` | ||
If installed, you can just `npm run export-to-tabletop-simulator` | ||
In Tabletop Simulator, go to Host > Chest > Saved Objects and find Card Game. | ||
## Update cards | ||
* Edit `cards.json` and preview with `index.html` | ||
* `npm run export` | ||
* `npm run export-to-tabletop-simulator` | ||
<!-- When there are multiple card sets: | ||
You can `set PARALLEL_EXPORT=ON` before running `export` to speed it up significantly **IF** it's on a powerful enough machine. | ||
If it's not powerful enough it might freeze up the entire computer. | ||
It needs a lot of video memory. | ||
--> | ||
|
||
## TODO | ||
|
||
* API | ||
|
||
|
||
|
||
[Node.js]: https://nodejs.org/en/ | ||
[Tabletop Simulator]: http://store.steampowered.com/app/286160/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
<title>Exporting Cards</title> | ||
<script src="../src/export.coffee" type="text/coffeescript"></script> | ||
<script src="lib/coffee-script.js"></script> |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"name": "card-game-exporter", | ||
"version": "0.0.0", | ||
"description": "Just the nw-based exporting component of card-game-exporter", | ||
"main": "export.html" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="utf-8"> | ||
<title>Cards</title> | ||
<meta name="viewport" content="width=device-width, initial-scale=1"> | ||
<link rel="stylesheet" href="styles/reset.css"> | ||
<link rel="stylesheet" href="styles/cards.css"> | ||
<link rel="stylesheet" href="styles/counters.css"> | ||
<style type="text/css"> | ||
body, html { | ||
width: 100%; | ||
height: 100%; | ||
margin: 0; | ||
border: 0; | ||
padding: 0; | ||
font-family: "Helvetica"; | ||
text-align: center; | ||
} | ||
.card { | ||
display: inline-block; | ||
vertical-align: bottom; | ||
margin: 0.5cm; | ||
} | ||
h2 { | ||
font-size: 2em; | ||
margin: 0.2em; | ||
} | ||
</style> | ||
</head> | ||
<body> | ||
<script src="lib/jquery-2.1.1.min.js"></script> | ||
<script src="lib/coffee-script.js"></script> | ||
<script src="src/render.coffee" type="text/coffeescript"></script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
{ | ||
"name": "card-game-generator", | ||
"version": "0.1.0", | ||
"description": "A card game development toolkit", | ||
"scripts": {}, | ||
"main": "src/card-game-generator.coffee", | ||
"devDependencies": { | ||
"async": "^1.5.2", | ||
"coffee-script": "^1.10.0", | ||
"nw": "^0.12.3" | ||
}, | ||
"os": "win32", | ||
"dependencies": { | ||
"mkdirp": "^0.5.1" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
|
||
mkdirp = require "mkdirp" | ||
fs = require "fs" | ||
path = require "path" | ||
{spawn} = require "child_process" | ||
nw = (require "nw").findpath() | ||
create_save = require "./create-save" | ||
|
||
# TODO: cross-platform! | ||
ts_folder = "#{process.env.USERPROFILE}/Documents/My Games/Tabletop Simulator" | ||
|
||
module.exports = | ||
class CardGameGenerator | ||
constructor: ({@cardSets, @counters, @imagesURL, @exportedImagesURL, @saveName})-> | ||
@counters ?= {} | ||
|
||
export: ({page, exportFolder, cardWidth, cardHeight, scale, debug}, callback)-> | ||
exportFolder = path.resolve(exportFolder) | ||
page = path.resolve(page) | ||
mkdirp(exportFolder) | ||
mkdirp(page) | ||
json_args = JSON.stringify({@cardSets, page, exportFolder, cardWidth, cardHeight, scale, debug}) | ||
nw_process = spawn(nw, [path.join(__dirname, "../exporter"), json_args]) | ||
nw_process.on "error", callback | ||
nw_process.on "exit", (code)-> | ||
callback() if code is 0 | ||
|
||
exportToTabletopSimulator: ({exportFolder, saveName})-> | ||
exportFolder = path.resolve(exportFolder) | ||
|
||
save = create_save({@imagesURL, @exportedImagesURL, @cardSets}) | ||
|
||
save_json = JSON.stringify(save, null, 2) | ||
|
||
fs.writeFileSync "#{exportFolder}/#{saveName}.json", save_json, "utf8" | ||
|
||
chest_folder = "#{ts_folder}/Saves/Chest" | ||
fs.writeFileSync "#{chest_folder}/#{saveName}.json", save_json, "utf8" | ||
|
||
@clearTabletopSimulatorCache() | ||
|
||
clearTabletopSimulatorCache: -> | ||
cache_folder = "#{ts_folder}/Mods/Images" | ||
for fname in fs.readdirSync cache_folder | ||
fs.unlinkSync "#{cache_folder}/#{fname}" |
Oops, something went wrong.