Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
1cc01f2
Add mine theme barrels
oli414 Apr 17, 2022
b4d8b87
Update ignore
oli414 Apr 17, 2022
503d71d
Apply gitignore changes
oli414 Apr 17, 2022
867b605
Apply gitignore changes
oli414 Apr 17, 2022
59db7a1
Apply gitignore changes
oli414 Apr 17, 2022
8063f41
Exclude object.json files
oli414 Apr 17, 2022
e1af688
Remove object.json files
oli414 Apr 17, 2022
5d1e9be
Add manifest.json
oli414 Apr 17, 2022
02cde9d
Update manifest
oli414 Apr 17, 2022
b0e3654
Move textures to a theme textures folder
oli414 Apr 17, 2022
281394c
Increase texture res back
oli414 Apr 17, 2022
b4ffbf9
Fix less rusty metal size
oli414 Apr 17, 2022
a97ddaa
Add logs
oli414 Apr 17, 2022
ca9e915
Add wheels object
oli414 Apr 17, 2022
28e2327
Update manifest
oli414 Apr 17, 2022
a946630
Fix manifest version
oli414 Apr 17, 2022
1e50088
Update JSON files
IntelOrca Apr 24, 2022
4ca53f2
Add build script
IntelOrca Apr 24, 2022
ccd4589
improve lighting
oli414 Apr 25, 2022
e5ae6b2
Merge
oli414 Apr 25, 2022
ebf411d
Update JSON objects to not use palette keep
IntelOrca Apr 26, 2022
0afe5c0
Update build.mjs
IntelOrca Apr 26, 2022
60556a2
Support .png and gx files
IntelOrca Apr 26, 2022
e5c2d47
Use 7z for windows
IntelOrca Apr 28, 2022
f6bba32
Add 7z. Fix out folder not created before read
oli414 Apr 29, 2022
1de4c9e
Merge branch 'barrels' of https://github.com/oli414/OpenGraphics into…
oli414 Apr 29, 2022
dea8599
Specify zip format for 7z command
oli414 Apr 29, 2022
db415c7
Remove unused console out
oli414 Apr 29, 2022
44a7d56
Update object gx files
oli414 May 17, 2022
5c64585
Remove ignored files
oli414 May 17, 2022
a679a01
Remove unused object manifest
oli414 May 17, 2022
b6d267a
Update build script
IntelOrca May 19, 2022
961c503
Use temp folder
IntelOrca May 19, 2022
bfd72dc
Change name of asset pack
IntelOrca May 19, 2022
268a914
Add CI script
IntelOrca May 19, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: CI
on: [push, pull_request]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Download gxc
run: |
curl -Lo tools.tar.gz https://github.com/IntelOrca/libsawyer/releases/download/v1.1.0/libsawyer-tools-musl-x64.tar.gz
tar -C /usr/bin -xf tools.tar.gz
- name: Create graphics asset pack
run: node build.mjs --verbose
- name: Upload artifacts
uses: actions/upload-artifact@v2
with:
name: "OpenRCT2 Open Graphics Asset Pack"
path: out/**/*
14 changes: 7 additions & 7 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
temp/
out/
*.parkobj

#Hidden folders/files
.*/
.*
!.gitignore
*.png
/rct2/**/sprites/
sprites.json
/rct2/**/object.json

# Blender Autosave files
*.blend1


#OS special files
*~
.fuse_hidden*
Expand Down Expand Up @@ -41,4 +41,4 @@ Icon
.AppleDesktop
Network Trash Folder
Temporary Items
.apdisk
.apdisk
283 changes: 283 additions & 0 deletions build.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,283 @@
#!/usr/bin/env node
import fs from 'fs';
import path from 'path';
import { spawn } from 'child_process';
import { platform } from 'os';

const verbose = process.argv.indexOf('--verbose') != -1;

async function main() {
const objects = [];
for (const dir of ['rct2', 'openrct2']) {
const moreObjects = await getObjects(dir);
objects.push(...moreObjects);
}

// Process all objects with gx files first before those with .png files
objects.sort((a, b) => {
if (typeof a.images === typeof b.images) return 0;
if (typeof a.images === 'string') return -1;
return 1;
});

await mkdir('out');
await mkdir('temp');

const manifest = await readJsonFile('manifest.json');
manifest.objects = [];
const singleSpriteManifest = [];
const gxMergeList = [];
let imageIndex = 0;
for (const obj of objects) {
console.log(`Processing ${obj.id}...`);

let numImages;
const images = obj.images;

if (typeof images === 'string') {
const result = images.match(/^\$LGX:(.+)\[([0-9]+)\.\.([0-9]+)\]$/);
if (result) {
const fileName = result[1];
const index = parseInt(result[2]);
const length = parseInt(result[3]);
gxMergeList.push(path.join(obj.cwd, fileName));
numImages = length - index + 1;
} else {
const result = images.match(/^\$LGX:(.+)$/);
if (result) {
const fileName = result[1];
const fullPath = path.join(obj.cwd, fileName);
gxMergeList.push(fullPath);
numImages = await getGxImageCount('out', fullPath);
} else {
throw new Error(`Unsupported image format: ${images}`);
}
}
} else {
for (const image of images) {
image.path = path.join(obj.cwd, image.path);
}
singleSpriteManifest.push(...images);
numImages = images.length;
}

obj.images = `$LGX:images.dat[${imageIndex}..${imageIndex + numImages - 1}]`;
obj.cwd = undefined;
manifest.objects.push(obj);
imageIndex += numImages;
}
gxMergeList.push('images.dat');

console.log(`Building asset pack...`);
await writeJsonFile('temp/manifest.json', manifest);
await writeJsonFile('temp/images.json', singleSpriteManifest);
await compileGx('temp', 'images.json', 'images.dat');
if (gxMergeList.length >= 2) {
await mergeGx('temp', gxMergeList, 'images.dat');
}

const outFilename = `${manifest.id}.parkap`
const outPath = path.join('../out/', outFilename);
await zip('temp', outPath, ['manifest.json', 'images.dat']);
rm('temp');
console.log(`${outFilename} created successfully`);
}

async function getObjects(dir) {
const result = [];
const files = await getAllFiles(dir);
for (const file of files) {
const jsonRegex = /^.+\..+\.json$/;
if (jsonRegex.test(file)) {
const cwd = path.join('..', path.dirname(file));
const obj = await readJsonFile(file);
obj.cwd = cwd;
result.push(obj);
}
}
return result;
}

function compileGx(cwd, manifest, outputFile) {
return startProcess('gxc', ['build', outputFile, manifest], cwd);
}

async function mergeGx(cwd, inputFiles, outputFile) {
await startProcess('gxc', ['merge', outputFile, inputFiles[inputFiles.length - 2], inputFiles[inputFiles.length - 1]], cwd);
for (let i = inputFiles.length - 3; i >= 0; i--) {
await startProcess('gxc', ['merge', outputFile, inputFiles[i], outputFile], cwd);
}
}

async function getGxImageCount(cwd, inputFile) {
const stdout = await startProcess('gxc', ['details', inputFile], cwd);
const result = stdout.match(/numEntries: ([0-9]+)/);
if (result) {
return parseInt(result[1]);
} else {
throw new Error(`Unable to get number of images for gx file: ${inputFile}`);
}
}

function readJsonFile(path) {
return new Promise((resolve, reject) => {
fs.readFile(path, 'utf8', (err, data) => {
if (err) {
reject(err);
} else {
resolve(JSON.parse(data));
}
});
});
}

function writeJsonFile(path, data) {
return new Promise((resolve, reject) => {
const json = JSON.stringify(data, null, 4) + '\n';
fs.writeFile(path, json, 'utf8', err => {
if (err) {
reject(err);
} else {
resolve();
}
});
});
}

function zip(cwd, outputFile, paths) {
if (platform() == 'win32') {
return startProcess('7z', ['a', '-tzip', outputFile, ...paths], cwd);
} else {
return startProcess('zip', [outputFile, ...paths], cwd);
}
}

function startProcess(name, args, cwd) {
return new Promise((resolve, reject) => {
const options = {};
if (cwd) options.cwd = cwd;
if (verbose) {
console.log(`Launching \"${name} ${args.join(' ')}\"`);
}
const child = spawn(name, args, options);
let stdout = '';
child.stdout.on('data', data => {
stdout += data;
});
child.stderr.on('data', data => {
stdout += data;
});
child.on('error', err => {
if (err.code == 'ENOENT') {
reject(new Error(`${name} was not found`));
} else {
reject(err);
}
});
child.on('close', code => {
if (code !== 0) {
reject(new Error(`${name} failed:\n${stdout}`));
} else {
resolve(stdout);
}
});
});
}

function mkdir(path) {
return new Promise((resolve, reject) => {
fs.access(path, (error) => {
if (error) {
fs.mkdir(path, err => {
if (err) {
reject(err);
} else {
resolve();
}
});
} else {
resolve();
}
});
});
}

function getAllFiles(root) {
return new Promise((resolve, reject) => {
const results = [];
let pending = 0;
const find = (root) => {
pending++;
fs.readdir(root, (err, fileNames) => {
// if (err) {
// reject(err);
// }
for (const fileName of fileNames) {
const fullPath = path.join(root, fileName);
pending++;
fs.stat(fullPath, (err, stat) => {
// if (err) {
// reject(err);
// }
if (stat) {
if (stat.isDirectory()) {
find(fullPath);
} else {
results.push(fullPath);
}
}
pending--;
if (pending === 0) {
resolve(results);
}
});
}
pending--;
if (pending === 0) {
resolve(results.sort());
}
});
};
find(root);
});
}

function rm(filename) {
if (verbose) {
console.log(`Deleting ${filename}`)
}
return new Promise((resolve, reject) => {
fs.stat(filename, (err, stat) => {
if (err) {
if (err.code == 'ENOENT') {
resolve();
} else {
reject();
}
} else {
if (stat.isDirectory()) {
fs.rm(filename, { recursive: true }, err => {
if (err) {
reject(err);
}
resolve();
});
} else {
fs.unlink(filename, err => {
if (err) {
reject(err);
}
resolve();
});
}
}
});
});
}

try {
await main();
} catch (err) {
console.log(err.message);
process.exitCode = 1;
}
16 changes: 16 additions & 0 deletions manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"id": "openrct2.graphics.opengraphics",
"authors": [
"OpenRCT2"
],
"version": "0.1",
"strings": {
"name": {
"en-GB": "Open Graphics"
},
"description": {
"en-GB": "The official OpenRCT2 asset pack that replicates the nostalgic graphical style",
"nl-NL": "Het officiële OpenRCT2 assetpakket dat de nostalgische grafische stijl repliceert"
}
}
}
Binary file not shown.
7 changes: 7 additions & 0 deletions rct2/scenery/MineTheming/Barrel1/rct2.scenery_small.tbr1.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"id": "rct2.scenery_small.tbr1",
"authors": [
"Oli414"
],
"images": "$LGX:output/images.dat"
}
Binary file added rct2/scenery/MineTheming/Barrel1/tbr1.blend
Binary file not shown.
Binary file not shown.
7 changes: 7 additions & 0 deletions rct2/scenery/MineTheming/Barrel2/rct2.scenery_small.tbr2.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"id": "rct2.scenery_small.tbr2",
"authors": [
"Oli414"
],
"images": "$LGX:output/images.dat"
}
Binary file added rct2/scenery/MineTheming/Barrel2/tbr2.blend
Binary file not shown.
Binary file not shown.
7 changes: 7 additions & 0 deletions rct2/scenery/MineTheming/Barrel3/rct2.scenery_small.tbr3.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"id": "rct2.scenery_small.tbr3",
"authors": [
"Oli414"
],
"images": "$LGX:output/images.dat"
}
Binary file added rct2/scenery/MineTheming/Barrel3/tbr3.blend
Binary file not shown.
Binary file not shown.
7 changes: 7 additions & 0 deletions rct2/scenery/MineTheming/Barrel4/rct2.scenery_small.tbr4.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"id": "rct2.scenery_small.tbr4",
"authors": [
"Oli414"
],
"images": "$LGX:output/images.dat"
}
Binary file added rct2/scenery/MineTheming/Barrel4/tbr4.blend
Binary file not shown.
Binary file added rct2/scenery/MineTheming/Logs/output/images.dat
Binary file not shown.
7 changes: 7 additions & 0 deletions rct2/scenery/MineTheming/Logs/rct2.scenery_small.tml.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"id": "rct2.scenery_small.tml",
"authors": [
"Oli414"
],
"images": "$LGX:output/images.dat"
}
Binary file added rct2/scenery/MineTheming/Logs/tml.blend
Binary file not shown.
Binary file added rct2/scenery/MineTheming/Wheels/output/images.dat
Binary file not shown.
7 changes: 7 additions & 0 deletions rct2/scenery/MineTheming/Wheels/rct2.scenery_small.tmw.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"id": "rct2.scenery_small.tmw",
"authors": [
"Oli414"
],
"images": "$LGX:output/images.dat"
}
Binary file added rct2/scenery/MineTheming/Wheels/tmw.blend
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added rct2/scenery/MineTheming/textures/BarrelWood.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added rct2/scenery/MineTheming/textures/Log/Bark.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added rct2/scenery/MineTheming/textures/Log/Stump.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added rct2/scenery/MineTheming/textures/RustyMetal.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.