Skip to content

Commit

Permalink
Release ZomboidMod v2.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
matshou committed Mar 5, 2021
2 parents 437d99a + 8387eeb commit 5ed5844
Show file tree
Hide file tree
Showing 26 changed files with 227 additions and 99 deletions.
6 changes: 1 addition & 5 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,6 @@ local.properties
# Libraries
/lib/

# Zmod resources
/media/*
!/media/zmod/

### IntelliJ ###

# Project file-based format
Expand Down Expand Up @@ -41,7 +37,7 @@ logs/
build/

# Exclude gradle-wrapper.jar from rules
!/gradle/wrapper/gradle-wrapper.jar
!**/wrapper/gradle-wrapper.jar

### Windows ###
# Windows thumbnail cache files
Expand Down
4 changes: 4 additions & 0 deletions .idea/.gitignore

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

11 changes: 0 additions & 11 deletions .idea/runConfigurations/Debug_Zomboid.xml

This file was deleted.

11 changes: 0 additions & 11 deletions .idea/runConfigurations/Run_Zomboid.xml

This file was deleted.

1 change: 1 addition & 0 deletions .idea/runConfigurations/initializeMod.xml

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

2 changes: 2 additions & 0 deletions .idea/runConfigurations/setupWorkspace.xml

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

2 changes: 1 addition & 1 deletion .idea/scopes/pz_java.xml

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

41 changes: 24 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,15 +61,15 @@ Instead, obtain the latest release and follow the [installation](#installation)

- <details>
<summary>Open the project as a Gradle project with Intellij IDEA<a href="https://www.jetbrains.com/help/idea/gradle.html#gradle_import_project_start"><sup>?</sup></a>.</summary>
<br><img src="./media/zmod/open_project.png" width=75%/>
<br><img src="./media/zmod/load_gradle_project.png" width=40%/>
<br><img src="images/open_project.png" width=75%/>
<br><img src="images/load_gradle_project.png" width=40%/>
</details>

- Ensure project SDK is set to JDK 8[<sup>?</sup>](https://www.jetbrains.com/help/idea/sdk.html#change-project-sdk).

- <details>
<summary>Initialize mod by running <code>initializeMod</code> run configuration<a href="https://www.jetbrains.com/help/idea/run-debug-configuration.html"><sup>?</sup></a>.</summary>
<br><img src="./media/zmod/init_mod.gif" width=65%/>
<br><img src="images/init_mod.gif" width=65%/>
</details>

- Prepare workspace by running `setupWorkspace` run configuration[<sup>?</sup>](https://www.jetbrains.com/help/idea/run-debug-configuration.html).
Expand All @@ -78,20 +78,20 @@ Instead, obtain the latest release and follow the [installation](#installation)

- <details>
<summary>Attach decompiled sources to classes.</summary>
<br/><img src="./media/zmod/module_dependencies.png" width=100%/>
<br/><br/><img src="./media/zmod/module_library.png" width=65%/>
</details>

- <details>
<summary>Update application run configurations.</summary>
<p>Set application configurations module field to <code>&ltmod_id&gt.main</code>. For example if your mod ID was <code>awesome-mod</code> you would set the module field to <code>awesome-mod.main</code>.</p>
<br/><img src="./media/zmod/update_run_configs.png" width=100%/>
</details>

- <details>
<summary>Update project search scopes.</summary>
<p>Navigate to <code>File -> Settings -> Appearance & Behaviour -> Scopes</code> and update all search scope module references to match your project module. For example if your mod ID was <code>awesome-mod</code> you would set the module field to <code>awesome-mod.media</code>.</p>
<br/><img src="./media/zmod/project_search_scopes.png" width=100%/>
<ul>
<li>Open project structure - <code>File -> Project Structure...</code></li>
<li>Open <code>modules -> main -> Dependencies</code> panel.</li>
<li>Find and select <code>zomboid-&ltversion&gt.jar</code> dependency.</li>
<li>Click the little pencil icon to edit depdendency properties.</li>
</ul>
<img src="images/module_dependencies.png" width=100%/>
<p>You should now be in the window called <code>Configure Module Library</code>.</p>
<ul>
<li>Click the little plus icon (<code>Alt + Insert</code>) to attach files.</li>
<li>In the new explorer window that just popped up find and select compiled sources which should be in <code>./lib/zomboid-&ltversion&gt-sources.jar</code> in project root directory.</li>
<li>Click <code>OK</code> in all open windows to save and apply settings.</li>
</ul>
<img src="images/module_library.png" width=65%/>
</details>

### License
Expand All @@ -118,8 +118,15 @@ Note that you can choose to include your full name or your Github username. It i

## How to use

### Setup tasks

- `createLaunchRunConfigs` - Create game launch run configurations.
- `createModSearchScopes` - Create IDEA search scopes for mod files.
- `initLocalProperties` - Initialize local project properties.

### Mod tasks

- `applyModTemplate` - Apply Project Zomboid mod template.
- `createModStructure` - Create default mod directory structure.
- `initModInfo` - Initialize mod metadata information.
- `loadModInfo` - Load mod metadata information.
Expand Down
7 changes: 7 additions & 0 deletions dist/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ local.properties
# Libraries
/lib/

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

### IntelliJ ###

# Project file-based format
Expand Down Expand Up @@ -33,6 +37,9 @@ logs/
# Ignore Gradle build output directory
build/

# Exclude gradle-wrapper.jar from rules
!**/wrapper/gradle-wrapper.jar

### Windows ###
# Windows thumbnail cache files
Thumbs.db
Expand Down
File renamed without changes.
File renamed without changes.
72 changes: 48 additions & 24 deletions distribution.gradle
Original file line number Diff line number Diff line change
@@ -1,56 +1,80 @@
import org.gradle.util.GFileUtils

def stagePath = file("$buildDir/tmp/distribution/stage").toPath()
def stagePath = file("stage").toPath()
task cleanDistributionStage(type: Delete) {

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

it.onlyIf {
file(stagePath).exists()
}
delete(stagePath)
}
def docsList = [ 'README.md', 'LICENSE.txt', 'CHANGELOG.md' ]
tasks.register('stageDistribution', Copy.class) {

description('Copy distribution files to stage directory.')
group('distribution')
it.description 'Copy distribution files to stage directory.'
it.group 'distribution'

it.from projectDir
it.into stagePath

// files that need to be excluded
it.exclude '/README.md', '/LICENSE.txt', '/.gitignore',
'.gitignored', 'distribution.sh', 'distribution.gradle',
'.idea/runConfigurations/distribution.xml', 'mod.info'
it.exclude '**/stage/', '/.gitignore', '.gitignored', 'distribution.sh', 'distribution.gradle',
'.idea/runConfigurations/distribution.xml', 'mod.info', '.idea/scopes/mod_*'

// dirs that are already excluded but we don't want to spend time on staging
it.exclude '/dist/**', '.gradle/**', 'buildSrc/.gradle/**', '/build/**',
'buildSrc/build/**', '/lib/**', '/media/**', '/logs/**'

// include project documentation
it.into('docs/zmod') {
it.from projectDir
it.include docsList + 'images/*'
}
// do additional copy actions we cannot do with this Copy task
it.doLast {
file('dist').listFiles().each {
GFileUtils.copyFile(it, stagePath.resolve(it.getName()).toFile() as File)
}
def gitIgnored = file('.gitignored')
if (gitIgnored.exists())
{
def ignoredFiles = GFileUtils.readFile(gitIgnored).split('\r|\n|\r\n')
ignoredFiles.each {
File ignoredFile = stagePath.resolve(it).normalize().toFile()
if (ignoredFile.exists() && !ignoredFile.isDirectory() && !ignoredFile.delete()) {
logger.warn("WARN: Unable to delete ${ignoredFile.path}")
}
/*
* copy additional distribution files manually because files
* excluded by task filters cannot be copied with Copy task
*/
if (it.directory) {
GFileUtils.copyDirectory(it, stagePath.resolve(it.getName()).toFile() as File)
}
else GFileUtils.copyFile(it, stagePath.resolve(it.getName()).toFile() as File)
}
// remove duplicate docs in root directory
docsList.forEach({
GFileUtils.deleteQuietly(stagePath.resolve(it).toFile())
})
}
it.dependsOn(cleanDistributionStage)
}

tasks.register('pruneDistributionStage', Delete.class) {

it.description 'Selectively delete files from distribution stage.'
it.group 'distribution'

def gitIgnored = file('.gitignored')
it.onlyIf {
file(stagePath).exists() && gitIgnored.exists()
}
it.doLast {
def ignoredFiles = GFileUtils.readFile(gitIgnored).split('\r|\n|\r\n')
ignoredFiles.each { s ->
File ignoredFile = file(s)
if (ignoredFile.toPath().toAbsolutePath().startsWith(stagePath.toAbsolutePath())) {
it.delete(ignoredFile)
logger.quiet("Deleting ignored file ${s}")
}
}
}
}

distributions.main.contents {
it.from stagePath
it.includeEmptyDirs false
}

// All distribution tasks need to first stage files
[ distZip, distTar, assembleDist, installDist ].forEach {
it.dependsOn(stageDistribution)
}
22 changes: 20 additions & 2 deletions distribution.sh
Original file line number Diff line number Diff line change
@@ -1,8 +1,26 @@
#!/bin/bash
echo Listing files ignored by git...

printf 'Staging distribution...\n'
./gradlew stageDistribution

printf '\nListing files ignored by git...\n'

# disable distribution gitignore
mv stage/.gitignore stage/.gitignore_

find . -path ./.git -prune -o -print | git check-ignore --no-index --stdin > .gitignored

echo Assembling distribution...
# enable distribution gitignore
mv stage/.gitignore_ stage/.gitignore

printf '\nPruning distribution stage...\n'
./gradlew pruneDistributionStage

printf '\nAssembling distribution...\n'
./gradlew assembleDist

printf '\nCleaning distribution stage...\n'
./gradlew cleanDistributionStage

printf '\n'
read -p "Press enter to continue"
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
Binary file added images/path_variables.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes
File renamed without changes
29 changes: 21 additions & 8 deletions mod.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,8 @@ void validateModInfo() {

def saveModInfo = tasks.register('saveModInfo') {

description('Save mod metadata to file.')
group('mod')
it.description 'Save mod metadata to file.'
it.group 'mod'

it.doLast {
// validate properties before saving them
Expand Down Expand Up @@ -155,9 +155,12 @@ def saveModInfo = tasks.register('saveModInfo') {

tasks.register('initModInfo') {

description('Initialize mod metadata information.')
group('mod')
it.description 'Initialize mod metadata information.'
it.group 'mod'

it.onlyIf {
!modInfoFile.exists()
}
it.doLast {
ant.input(message: 'Enter mod name: \n', addproperty: 'mod.name')
modInfoProperties.setProperty('name', ant.properties.get('mod.name') as String)
Expand Down Expand Up @@ -206,8 +209,9 @@ String getDisplayProperty(String name) {

task showModInfo {

description('Print mod metadata information.')
group('mod')
description 'Print mod metadata information.'
group 'mod'

onlyIf {
modInfoFile.exists()
}
Expand All @@ -230,8 +234,8 @@ task showModInfo {

task createModStructure {

group 'mod'
description 'Create default mod directory structure.'
group 'mod'

doLast {
def media = sourceSets.named('media').get()
Expand All @@ -242,4 +246,13 @@ task createModStructure {
project.mkdir(it)
})
}
}
}

tasks.register('applyModTemplate', Copy.class) {

it.description 'Apply Project Zomboid mod template.'
it.group 'mod'

it.into projectDir
it.from 'docs/template'
}
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.0.0
modversion=2.1.0
pzversion=41.50-IWBUMS
Loading

0 comments on commit 5ed5844

Please sign in to comment.