Skip to content

Commit

Permalink
Release ZomboidMod v2.2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
matshou committed Mar 7, 2021
2 parents 51a6036 + 34db376 commit 94b81f4
Show file tree
Hide file tree
Showing 12 changed files with 213 additions and 83 deletions.
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -78,3 +78,8 @@ $RECYCLE.BIN/
*.i*86
*.x86_64
*.hex

### Ruby ###

# No need for lock file in workflow
Gemfile.lock
1 change: 1 addition & 0 deletions .idea/runConfigurations/setupWorkspace.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
source 'https://rubygems.org'

gem "github_changelog_generator"
15 changes: 14 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# ZomboidMod

[![release](https://img.shields.io/github/v/release/cocolabs/pz-zmod)](https://github.com/cocolabs/pz-zmod/releases/latest) ![last-commit](https://img.shields.io/github/last-commit/cocolabs/pz-zmod/dev) [![License](https://img.shields.io/github/license/cocolabs/pz-zmod)](https://mit-license.org/) [![chat](https://img.shields.io/discord/717757483376050203?color=7289DA)](https://discord.gg/vCeydWCbd9)
[![release](https://img.shields.io/github/v/release/cocolabs/pz-zmod)](https://github.com/cocolabs/pz-zmod/releases/latest) ![last-commit](https://img.shields.io/github/last-commit/cocolabs/pz-zmod/dev) [![License](https://img.shields.io/github/license/cocolabs/pz-zmod)](https://mit-license.org/) [![chat](https://img.shields.io/discord/717757483376050203?color=7289DA&label=discord&logo=discord&logoColor=white)](https://discord.gg/vCeydWCbd9)

ZomboidMod is a compact mod development environment for [Project Zomboid](https://projectzomboid.com/blog/).

Expand Down Expand Up @@ -113,6 +113,19 @@ ZomboidMod distributions contain a template MIT license for your project to use.

Note that you can choose to include your full name or your Github username. It is a matter of preference and legally speaking both should be valid as long as you can prove the identity provided represents you.

### Discord integration

If you are a Discord user and want to let the world know that you are working hard on your Project Zomboid mods you can do so with IntelliJ IDEA Discord integration.

#### Installation

- Install [Discord Integration](https://plugins.jetbrains.com/plugin/10233-discord-integration) IDEA plugin from the marketplace.
- Run `createDiscordIntegration` task.[<sup>?</sup>](#discord-integration "This task will run automatically when you run setupWorkspace configuration".)

Note that you need to write mod metadata (`mod.info`) before creating Discord integration so that the integration displays correct project name and description. However the integration is automatically setup after running `setupWorkspace` so you don't have to worry about that.

You can rerun the task at any time if you accidentally delete the configuration file.[<sup>?</sup>](#a ".idea/discord.xml")

## How to use

### Setup tasks
Expand Down
19 changes: 14 additions & 5 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,28 @@ java {
apply from: 'setup.gradle'
if (project.ext.has('gameDir'))
{
List<String> resourcesList = new ArrayList<>()
Set<String> sourcesList = new HashSet<>(['media/lua'])
Set<String> resourcesList = new HashSet<>()
Set<String> excludeResources = new HashSet<>([
'media/lua', 'media/luaexamples',
'media/newuitests', 'media/launcher',
])
def gameDirPath = gameDir as java.nio.file.Path
//@formatter:off
gameDirPath.resolve('media').toFile().listFiles().each
{
if (it.directory) {
resourcesList.add("media/${it.name}")
if (it.directory)
{
String filepath = "media/${it.name}"
if (!excludeResources.contains(filepath)) {
resourcesList.add(filepath)
}
}
}//@formatter:on
sourceSets {
media {
java.srcDirs = ['media/lua']
resources.srcDirs resourcesList
java.srcDirs = sourcesList
resources.srcDirs = resourcesList
}
}
apply from: 'mod.gradle'
Expand Down
2 changes: 1 addition & 1 deletion dist/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ local.properties
# Libraries
/lib/

# Template
# Documentation
/docs/template/
/docs/zmod/

Expand Down
107 changes: 107 additions & 0 deletions dist/distribution.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
import java.nio.file.Files
import java.nio.file.Paths

// set repository owner and name
project.ext.set('repo.owner', 'cocolabs')
project.ext.set('repo.name', 'pz-zmod')

// changelog.gradle
apply from: 'https://git.io/JqJiC'

def getPathsRelativeToModule(moduleName, srcDirSet) {

def module = rootDir.toPath().resolve(moduleName)
def map = new HashMap<String, String>()

def srcDirs = srcDirSet.srcDirs.stream().withCloseable {
it.filter({ f -> f.exists() }).collect()
}
for (File srcDir : (srcDirs as List<File>))
{
Files.walk(srcDir.toPath()).withCloseable
{
def paths = it.filter({ Files.isRegularFile(it as java.nio.file.Path) }).collect()
for (java.nio.file.Path path : (paths as List<java.nio.file.Path>))
{
def srcDirPath = srcDir.toPath()
def relativePath = srcDirPath.relativize(path)
def srcDirName = module.relativize(srcDirPath)
map.put(relativePath.toString(), srcDirName.toString())
}
}
}
return map
}

static def getRelativeCopyPath(fcd, relativePathMap) {

def path = relativePathMap.get(Paths.get(fcd.path).toString())
if (path != null) {
return fcd.relativePath.prepend(path)
}
else throw new Exception("Unable to relativize copy path: $fcd.path")
}

def mediaClassesDir = "$buildDir/classes/lua/media"
task mediaClasses(type: Copy, overwrite: true) {

into mediaClassesDir
from(sourceSets.media.java.srcDirs) {
def mSources = getPathsRelativeToModule('media', sourceSets.media.java)
eachFile {
def fcd = it as FileCopyDetails
fcd.setRelativePath(getRelativeCopyPath(fcd, mSources))
}
}
includeEmptyDirs = false
}

processMediaResources {

includeEmptyDirs = false
def mResources = getPathsRelativeToModule('media', sourceSets.media.resources)
eachFile {
def fcd = it as FileCopyDetails
fcd.setRelativePath(getRelativeCopyPath(fcd, mResources))
}
}

def stagePath = "$buildDir/tmp/distribution/stage"
task cleanModDistributionStage(type: Delete) {

description 'Clean distribution stage directory.'
group 'distribution'

it.onlyIf {
file(stagePath).exists()
}
delete(stagePath)
}
tasks.register('stageModDistribution', Copy.class) {

it.description 'Copy mod distribution files to stage directory.'
it.group 'distribution'

it.from mediaClassesDir, "$buildDir/resources/media"
it.into stagePath

it.dependsOn(cleanModDistributionStage)
it.mustRunAfter('processMediaResources', 'mediaClasses')
}

distributions {
mod.contents {
it.from stagePath
it.into 'media'
}
}
installModDist {
def parentDir = destinationDir.parentFile.toPath()
destinationDir = parentDir.resolve(rootProject.name).toFile()
}
[ 'modDistTar', 'modDistZip' ].forEach({
def task = tasks.named(it).get() as AbstractArchiveTask
task.archiveBaseName.set(rootProject.name)
task.mustRunAfter('stageModDistribution')
})
assembleModDist.dependsOn('processMediaResources', 'mediaClasses', 'stageModDistribution')
12 changes: 10 additions & 2 deletions dist/docs/template/README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
# ZomboidMod

![Game Version](https://img.shields.io/badge/PZ%20Version-IWBUMS%3A%2041.47-red) [![License](https://img.shields.io/github/license/yooksi/pz-zmod)](https://mit-license.org/)
[![release](https://img.shields.io/github/v/release/cocolabs/pz-zmod)](https://github.
com/cocolabs/pz-zmod/releases/latest) ![Game Version](https://img.shields.io/badge/PZ%20Version-IWBUMS%3A%2041.47-red) [![License](https://img.shields.io/github/license/yooksi/pz-zmod)](https://mit-license.org/) [![chat](https://img.shields.io/discord/717757483376050203?color=7289DA&label=discord&logo=discord&logoColor=white)](https://discord.gg/vCeydWCbd9)

Short description of what this mod is all about.

> **TODO:** remember to update badge links to point to your mod repository.
## Motivation

A short description of the motivation behind the creation of this mod.
Expand All @@ -24,6 +27,8 @@ Write about things that make this mod great.

For more information read [How To Install / Uninstall Mods](https://theindiestone.com/forums/index.php?/topic/1395-how-to-install-uninstall-mods/) forum thread.

> **TODO**: remember to update link to `latest release` to point to your repository.
## How to use
Explain different ways in which your mod can be used in-game.

Expand All @@ -33,4 +38,7 @@ Give proper credits to those that helped make this project.

## License

MIT © [Yourname](https://github.com/cocolabs)
MIT © [Yourname](https://github.com/cocolabs)

> **TODO**: remember to update copyright text to apply the license to your project.
> Read more information on how to do this [here](https://github.com/cocolabs/pz-zmod#license).
11 changes: 7 additions & 4 deletions distribution.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import org.gradle.util.GFileUtils

apply from: 'dist/distribution.gradle'

def stagePath = file("stage").toPath()
task cleanDistributionStage(type: Delete) {

Expand Down Expand Up @@ -58,11 +60,12 @@ tasks.register('pruneDistributionStage', Delete.class) {
it.description 'Selectively delete files from distribution stage.'
it.group 'distribution'

// duplicate documentation directory
it.delete './stage/images'

def gitIgnored = file('.gitignored')
it.onlyIf {
file(stagePath).exists() && gitIgnored.exists()
}
it.doLast {
if (file(stagePath).exists() && gitIgnored.exists())
{
def ignoredFiles = GFileUtils.readFile(gitIgnored).split('\r|\n|\r\n')
ignoredFiles.each { s ->
File ignoredFile = file(s)
Expand Down
59 changes: 0 additions & 59 deletions mod.gradle
Original file line number Diff line number Diff line change
@@ -1,66 +1,7 @@
import java.nio.file.Files
import java.nio.file.Paths
import java.nio.file.Path
import java.util.regex.Pattern

apply plugin: 'java'

def getPathsRelativeToModule(moduleName, srcDirSet) {

def module = rootDir.toPath().resolve(moduleName)
def map = new HashMap<String, String>()

def srcDirs = srcDirSet.srcDirs.stream().withCloseable {
it.filter({ f -> f.exists() }).collect()
}
for (File srcDir : (srcDirs as List<File>))
{
Files.walk(srcDir.toPath()).withCloseable
{
def paths = it.filter({ Files.isRegularFile(it as Path) }).collect()
for (Path path : (paths as List<Path>))
{
def srcDirPath = srcDir.toPath()
def relativePath = srcDirPath.relativize(path)
def srcDirName = module.relativize(srcDirPath)
map.put(relativePath.toString(), srcDirName.toString())
}
}
}
return map
}

static def getRelativeCopyPath(fcd, relativePathMap) {

def path = relativePathMap.get(Paths.get(fcd.path).toString())
if (path != null) {
return fcd.relativePath.prepend(path)
}
else throw new Exception("Unable to relativize copy path: $fcd.path")
}

task mediaClasses(type: Copy, overwrite: true) {

includeEmptyDirs = false
from(sourceSets.media.java.srcDirs) {
def mSources = getPathsRelativeToModule('media', sourceSets.media.java)
eachFile {
def fcd = it as FileCopyDetails
fcd.setRelativePath(getRelativeCopyPath(fcd, mSources))
}
}
into "$buildDir/classes/java/media"
}

processMediaResources {

includeEmptyDirs = false
def mResources = getPathsRelativeToModule('media', sourceSets.media.resources)
eachFile {
def fcd = it as FileCopyDetails
fcd.setRelativePath(getRelativeCopyPath(fcd, mResources))
}
}
// This is where mod properties are stored
def modInfoFile = file('mod.info')
project.ext.modInfoProperties = new Properties()
Expand Down
2 changes: 1 addition & 1 deletion mod.info
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ poster=poster.png
description=Compact mod development environment.
id=pz-zmod
url=https://github.com/cocolabs/pz-zmod
modversion=2.1.0
modversion=2.2.0
pzversion=41.50-IWBUMS
Loading

0 comments on commit 94b81f4

Please sign in to comment.