Skip to content
Snippets Groups Projects
Commit 1662f4f8 authored by brickode's avatar brickode
Browse files

Merge branch 'pregmod-master' of https://gitgud.io/pregmodfan/fc-pregmod into nursery-dev

parents 28ddbd20 8c7ec241
No related branches found
No related tags found
3 merge requests!4381Nursery,!4269WIP: Nursery,!3489WIP: Nursery
Showing
with 347 additions and 144 deletions
...@@ -25,6 +25,7 @@ var/ ...@@ -25,6 +25,7 @@ var/
*.egg-info/ *.egg-info/
.installed.cfg .installed.cfg
*.egg *.egg
bin/*
# PyInstaller # PyInstaller
# Usually these files are written by a python script from a template # Usually these files are written by a python script from a template
...@@ -103,4 +104,5 @@ package.json ...@@ -103,4 +104,5 @@ package.json
fc-pregmod fc-pregmod
*.outline *.outline
*.todo *.todo
TODO.txt TODO.txt
\ No newline at end of file .vscode/settings.json
{ {
"eslint.enable": false
} }
\ No newline at end of file
...@@ -31,12 +31,12 @@ How to mod (basic doc): ...@@ -31,12 +31,12 @@ How to mod (basic doc):
1. All sources now in the src subdir, in separate files. 1 passage = 1 file. 1. All sources now in the src subdir, in separate files. 1 passage = 1 file.
2. Special files and dir's: 2. Special files and dir's:
- src/config - configuration of the story is here. - src/config - configuration of the story is here.
- src/config/start.tw - contains list of .tw passage files, regenerated automatic, by building scripts. Do not change by hands. (original passage Start from pregmod renamed and moved to src/events/intro/introSummary.tw) - src/config/start.tw - contains list of .tw passage files, regenerated automatic, by building scripts. Do not change by hands. (original passage Start from pregmod renamed and moved to src/events/intro/introSummary.tw)
- src/js/storyJS.tw - special passage with [script] tag - contain all native JavaScript from pregmod. - src/js/storyJS.tw - special passage with [script] tag - contain all native JavaScript from pregmod.
- devTools/tweeGo/targets/sugarcube-2/userlib.js - on original FC JS moved here (I deleted it after moving JS to storyJS.tw). Compare to storyJS.tw but do not copy file here. May conflict with src/js/storyJS.tw if copied. - devTools/tweeGo/targets/sugarcube-2/userlib.js - on original FC JS moved here (I deleted it after moving JS to storyJS.tw). Compare to storyJS.tw but do not copy file here. May conflict with src/js/storyJS.tw if copied.
- src/pregmod - I put all pregmod-only passages here. - src/pregmod - I put all pregmod-only passages here.
- .gitignore - special file for git - to ignore some files. For example - compilation results. - .gitignore - special file for git - to ignore some files. For example - compilation results.
3. Compilation: 3. Compilation:
......
No preview for this file type
# Ignore everything in this directory
*
# Except the following:
!.gitignore
\ No newline at end of file
#!/bin/bash #!/bin/bash
mkdir -p bin
while [[ "$1" ]] while [[ "$1" ]]
do do
case $1 in case $1 in
...@@ -68,4 +70,3 @@ sed -i -e '/^.*<div id="store-area".*$/s/\\t/\t/g' -e '/^.*<div id="store-area". ...@@ -68,4 +70,3 @@ sed -i -e '/^.*<div id="store-area".*$/s/\\t/\t/g' -e '/^.*<div id="store-area".
&& mv bin/FC_pregmod_tmp.html bin/FC_pregmod.html && mv bin/FC_pregmod_tmp.html bin/FC_pregmod.html
echo "bin/FC_pregmod.html compilation finished." echo "bin/FC_pregmod.html compilation finished."
#!/bin/bash #!/bin/bash
mkdir -p bin
# Run sanity check. # Run sanity check.
./sanityCheck ./sanityCheck
......
@echo off
:: Free Cities Basic Compiler - Windows
:: Set working directory
pushd %~dp0
:: See if we can find a git installation
setlocal enabledelayedexpansion
for %%k in (HKCU HKLM) do (
for %%w in (\ \Wow6432Node\) do (
for /f "skip=2 delims=: tokens=1*" %%a in ('reg query "%%k\SOFTWARE%%wMicrosoft\Windows\CurrentVersion\Uninstall\Git_is1" /v InstallLocation 2^> nul') do (
for /f "tokens=3" %%z in ("%%a") do (
set GIT=%%z:%%b
set GITFOUND=yes
goto FOUND
)
)
)
)
:FOUND
if %GITFOUND% == yes (
set "PATH=%GIT%bin;%PATH%"
bash --login -c ./java+gitGrep-sanityCheck.sh
)
:: Compile the game
call "%~dp0compile.bat"
if %GITFOUND% == yes (
:: Make the output prettier, replacing \t with a tab and \n with a newline
bash -c "sed -i -e '/^.*<div id=\"store-area\".*$/s/\\\t/\t/g' -e '/^.*<div id=\"store-area\".*$/s/\\\n/\n/g' bin/FC_pregmod.html"
:: Revert ./src/init/storyInit.tw for next compilation
git checkout -- ./src/init/storyInit.tw
)
popd
PAUSE
#!/bin/bash
mkdir -p bin
# Run sanity check.
./java+gitGrep-sanityCheck.sh
HASH="$(git rev-list -n 1 --abbrev-commit HEAD)"
export TWEEGO_PATH=devTools/tweeGo/storyFormats
TWEEGO_EXE="tweego"
if hash $TWEEGO_EXE 2>/dev/null; then
echo "system tweego binary"
else
case "$(uname -m)" in
x86_64|amd64)
echo "x64 arch"
if [ "$(uname -s)" = "Darwin" ]; then
TWEEGO_EXE="./devTools/tweeGo/tweego_osx64"
else
TWEEGO_EXE="./devTools/tweeGo/tweego_nix64"
fi
;;
x86|i[3-6]86)
echo "x86 arch"
if [ "$(uname -s)" = "Darwin" ]; then
TWEEGO_EXE="./devTools/tweeGo/tweego_osx86"
else
TWEEGO_EXE="./devTools/tweeGo/tweego_nix86"
fi
;;
*)
echo "No system tweego binary found, and no precompiled binary for your platform available"
echo "Please compile tweego and put the executable in PATH"
exit 2
esac
fi
$TWEEGO_EXE -o "bin/FC_pregmod_${HASH}_tmp.html" src/
#Make the output prettier, replacing \t with a tab and \n with a newline
sed -i -e '/^<div id="store-area".*$/s/\\t/\t/g' -e '/^<div id="store-area".*$/s/\\n/\n/g' "bin/FC_pregmod_${HASH}_tmp.html" \
&& mv "bin/FC_pregmod_${HASH}_tmp.html" "bin/FC_pregmod_${HASH}.html"
echo "FC_pregmod_$HASH.html compilation finished."
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
:: Set working directory :: Set working directory
pushd %~dp0 pushd %~dp0
if not exist "bin\" mkdir bin
:: Run the appropriate compiler for the user's CPU architecture. :: Run the appropriate compiler for the user's CPU architecture.
if %PROCESSOR_ARCHITECTURE% == AMD64 ( if %PROCESSOR_ARCHITECTURE% == AMD64 (
CALL "%~dp0devTools\tweeGo\tweego_win64.exe" -o "%~dp0bin/FC_pregmod.html" "%~dp0src" CALL "%~dp0devTools\tweeGo\tweego_win64.exe" -o "%~dp0bin/FC_pregmod.html" "%~dp0src"
......
...@@ -349,3 +349,11 @@ UtilJS [script] ...@@ -349,3 +349,11 @@ UtilJS [script]
HackingSkillMultiplier() - outputs a value based off of the PC's hacking skill. HackingSkillMultiplier() - outputs a value based off of the PC's hacking skill.
upgradeMultiplierArcology() - outputs a value based off of the PC's engineering skill. upgradeMultiplierArcology() - outputs a value based off of the PC's engineering skill.
passageLink() - Creates a HTML element with custom SugarCube attributes which works as a passage link
SkillIncrease() - Depeciates the sugarcube fuctions.
jsNdef - A .js port of sugarcube's ndef.
jsDef - A .js port of sugarcube's def.
\ No newline at end of file
...@@ -2,6 +2,13 @@ Pregmod ...@@ -2,6 +2,13 @@ Pregmod
0.10.7.1-2.2.x 0.10.7.1-2.2.x
03/15/2019
5
-fixes
-code cleaning
-CSS tweaks to intro summary
03/13/2019 03/13/2019
4 4
......
...@@ -812,7 +812,7 @@ ...@@ -812,7 +812,7 @@
<<if ($activeSlave.actualAge >= _partnerSlave.actualAge+10) && canTalk(_partnerSlave)>> <<if ($activeSlave.actualAge >= _partnerSlave.actualAge+10) && canTalk(_partnerSlave)>>
tidying up their room together. _partnerSlave.slaveName is chattering about _his2 day, while $activeSlave.slaveName listens quietly, smiling fondly at $his _activeSlaveRel's prattle. tidying up their room together. _partnerSlave.slaveName is chattering about _his2 day, while $activeSlave.slaveName listens quietly, smiling fondly at $his _activeSlaveRel's prattle.
<<elseif ($activeSlave.amp !== 1) && !canTalk($activeSlave)>> <<elseif ($activeSlave.amp !== 1) && !canTalk($activeSlave)>>
getting ready for bed. $activeSlave.slaveName is using gestures to tell $his $activeSlave.slaveName about $his day; _partnerSlave.slaveName is very patient and does _his2 best to follow. getting ready for bed. $activeSlave.slaveName is using gestures to tell $his _activeSlaveRel about $his day; _partnerSlave.slaveName is very patient and does _his2 best to follow.
<<elseif ($activeSlave.behavioralQuirk == "confident") && canTalk($activeSlave)>> <<elseif ($activeSlave.behavioralQuirk == "confident") && canTalk($activeSlave)>>
finishing up a meal together. $activeSlave.slaveName is concluding a story, $his clear confident voice ringing as $he relates a slight. finishing up a meal together. $activeSlave.slaveName is concluding a story, $his clear confident voice ringing as $he relates a slight.
<<elseif ($activeSlave.behavioralQuirk == "cutting") && canTalk($activeSlave)>> <<elseif ($activeSlave.behavioralQuirk == "cutting") && canTalk($activeSlave)>>
......
...@@ -2,65 +2,65 @@ diff -r cd5d732c8669 src/lib/jquery-plugins.js ...@@ -2,65 +2,65 @@ diff -r cd5d732c8669 src/lib/jquery-plugins.js
--- a/src/lib/jquery-plugins.js Fri Mar 09 07:43:39 2018 -0600 --- a/src/lib/jquery-plugins.js Fri Mar 09 07:43:39 2018 -0600
+++ b/src/lib/jquery-plugins.js Fri Jan 25 18:37:15 2019 +0100 +++ b/src/lib/jquery-plugins.js Fri Jan 25 18:37:15 2019 +0100
@@ -37,6 +37,10 @@ @@ -37,6 +37,10 @@
return function () { return function () {
const $this = jQuery(this); const $this = jQuery(this);
+ const dataPassage = $this.attr('data-passage'); + const dataPassage = $this.attr('data-passage');
+ const initialDataPassage = window && window.SugarCube && window.SugarCube.State && window.SugarCube.State.passage; + const initialDataPassage = window && window.SugarCube && window.SugarCube.State && window.SugarCube.State.passage;
+ const savedYOffset = window.pageYOffset; + const savedYOffset = window.pageYOffset;
+ +
// Toggle "aria-pressed" status, if the attribute exists. // Toggle "aria-pressed" status, if the attribute exists.
if ($this.is('[aria-pressed]')) { if ($this.is('[aria-pressed]')) {
$this.attr('aria-pressed', $this.attr('aria-pressed') === 'true' ? 'false' : 'true'); $this.attr('aria-pressed', $this.attr('aria-pressed') === 'true' ? 'false' : 'true');
@@ -44,6 +48,11 @@ @@ -44,6 +48,11 @@
// Call the true handler. // Call the true handler.
fn.apply(this, arguments); fn.apply(this, arguments);
+ +
+ const doJump = function(){ window.scrollTo(0, savedYOffset); } + const doJump = function(){ window.scrollTo(0, savedYOffset); }
+ if ( dataPassage && (window.lastDataPassageLink === dataPassage || initialDataPassage === dataPassage)) + if ( dataPassage && (window.lastDataPassageLink === dataPassage || initialDataPassage === dataPassage))
+ doJump(); + doJump();
+ window.lastDataPassageLink = dataPassage; + window.lastDataPassageLink = dataPassage;
}; };
} }
diff -r cd5d732c8669 src/lib/simplestore/adapters/webstorage.js diff -r cd5d732c8669 src/lib/simplestore/adapters/webstorage.js
--- a/src/lib/simplestore/adapters/webstorage.js Fri Mar 09 07:43:39 2018 -0600 --- a/src/lib/simplestore/adapters/webstorage.js Fri Mar 09 07:43:39 2018 -0600
+++ b/src/lib/simplestore/adapters/webstorage.js Fri Jan 25 18:37:15 2019 +0100 +++ b/src/lib/simplestore/adapters/webstorage.js Fri Jan 25 18:37:15 2019 +0100
@@ -192,11 +192,11 @@ @@ -192,11 +192,11 @@
} }
static _serialize(obj) { static _serialize(obj) {
- return LZString.compressToUTF16(JSON.stringify(obj)); - return LZString.compressToUTF16(JSON.stringify(obj));
+ return JSON.stringify(obj); + return JSON.stringify(obj);
} }
static _deserialize(str) { static _deserialize(str) {
- return JSON.parse(LZString.decompressFromUTF16(str)); - return JSON.parse(LZString.decompressFromUTF16(str));
+ return JSON.parse((!str || str[0] == "{") ? str : LZString.decompressFromUTF16(str)); + return JSON.parse((!str || str[0] == "{") ? str : LZString.decompressFromUTF16(str));
} }
} }
diff -r cd5d732c8669 src/state.js diff -r cd5d732c8669 src/state.js
--- a/src/state.js Fri Mar 09 07:43:39 2018 -0600 --- a/src/state.js Fri Mar 09 07:43:39 2018 -0600
+++ b/src/state.js Fri Jan 25 18:37:15 2019 +0100 +++ b/src/state.js Fri Jan 25 18:37:15 2019 +0100
@@ -104,7 +104,7 @@ @@ -104,7 +104,7 @@
} }
if (_expired.length > 0) { if (_expired.length > 0) {
- stateObj.expired = [..._expired]; - stateObj.expired = [..._expired];
+ stateObj.expired = []; + stateObj.expired = [];
} }
if (_prng !== null) { if (_prng !== null) {
diff -r cd5d732c8669 src/ui.js diff -r cd5d732c8669 src/ui.js
--- a/src/ui.js Fri Mar 09 07:43:39 2018 -0600 --- a/src/ui.js Fri Mar 09 07:43:39 2018 -0600
+++ b/src/ui.js Fri Jan 25 18:37:15 2019 +0100 +++ b/src/ui.js Fri Jan 25 18:37:15 2019 +0100
@@ -337,6 +337,7 @@ @@ -337,6 +337,7 @@
if (saves.slots[i]) { if (saves.slots[i]) {
// Add the load button. // Add the load button.
$tdLoad.append( $tdLoad.append(
+ createButton('save', 'ui-close', L10n.get('savesLabelSave'), i, Save.slots.save), + createButton('save', 'ui-close', L10n.get('savesLabelSave'), i, Save.slots.save),
createButton('load', 'ui-close', L10n.get('savesLabelLoad'), i, slot => { createButton('load', 'ui-close', L10n.get('savesLabelLoad'), i, slot => {
jQuery(document).one(':dialogclose', () => Save.slots.load(slot)); jQuery(document).one(':dialogclose', () => Save.slots.load(slot));
}) })
...@@ -2,9 +2,9 @@ diff -r df721eb4cd55 src/lib/jquery-plugins.js ...@@ -2,9 +2,9 @@ diff -r df721eb4cd55 src/lib/jquery-plugins.js
--- a/src/lib/jquery-plugins.js Sun Dec 16 04:39:00 2018 -0600 --- a/src/lib/jquery-plugins.js Sun Dec 16 04:39:00 2018 -0600
+++ b/src/lib/jquery-plugins.js Fri Jan 25 00:54:01 2019 +0100 +++ b/src/lib/jquery-plugins.js Fri Jan 25 00:54:01 2019 +0100
@@ -43,14 +43,9 @@ @@ -43,14 +43,9 @@
return function () { return function () {
const $this = jQuery(this); const $this = jQuery(this);
- // Exit if the element is disabled. - // Exit if the element is disabled.
- // - //
- // NOTE: This should only be necessary for elements which are not disableable - // NOTE: This should only be necessary for elements which are not disableable
...@@ -16,58 +16,58 @@ diff -r df721eb4cd55 src/lib/jquery-plugins.js ...@@ -16,58 +16,58 @@ diff -r df721eb4cd55 src/lib/jquery-plugins.js
+ const dataPassage = $this.attr('data-passage'); + const dataPassage = $this.attr('data-passage');
+ const initialDataPassage = window && window.SugarCube && window.SugarCube.State && window.SugarCube.State.passage; + const initialDataPassage = window && window.SugarCube && window.SugarCube.State && window.SugarCube.State.passage;
+ const savedYOffset = window.pageYOffset; + const savedYOffset = window.pageYOffset;
// Toggle "aria-pressed" status, if the attribute exists. // Toggle "aria-pressed" status, if the attribute exists.
if ($this.is('[aria-pressed]')) { if ($this.is('[aria-pressed]')) {
@@ -59,6 +54,11 @@ @@ -59,6 +54,11 @@
// Call the true handler. // Call the true handler.
fn.apply(this, arguments); fn.apply(this, arguments);
+ +
+ const doJump = function(){ window.scrollTo(0, savedYOffset); } + const doJump = function(){ window.scrollTo(0, savedYOffset); }
+ if ( dataPassage && (window.lastDataPassageLink === dataPassage || initialDataPassage === dataPassage)) + if ( dataPassage && (window.lastDataPassageLink === dataPassage || initialDataPassage === dataPassage))
+ doJump(); + doJump();
+ window.lastDataPassageLink = dataPassage; + window.lastDataPassageLink = dataPassage;
}; };
} }
diff -r df721eb4cd55 src/lib/simplestore/adapters/webstorage.js diff -r df721eb4cd55 src/lib/simplestore/adapters/webstorage.js
--- a/src/lib/simplestore/adapters/webstorage.js Sun Dec 16 04:39:00 2018 -0600 --- a/src/lib/simplestore/adapters/webstorage.js Sun Dec 16 04:39:00 2018 -0600
+++ b/src/lib/simplestore/adapters/webstorage.js Fri Jan 25 00:54:01 2019 +0100 +++ b/src/lib/simplestore/adapters/webstorage.js Fri Jan 25 00:54:01 2019 +0100
@@ -189,11 +189,11 @@ @@ -189,11 +189,11 @@
} }
static _serialize(obj) { static _serialize(obj) {
- return LZString.compressToUTF16(JSON.stringify(obj)); - return LZString.compressToUTF16(JSON.stringify(obj));
+ return JSON.stringify(obj); + return JSON.stringify(obj);
} }
static _deserialize(str) { static _deserialize(str) {
- return JSON.parse(LZString.decompressFromUTF16(str)); - return JSON.parse(LZString.decompressFromUTF16(str));
+ return JSON.parse((!str || str[0] == "{") ? str : LZString.decompressFromUTF16(str)); + return JSON.parse((!str || str[0] == "{") ? str : LZString.decompressFromUTF16(str));
} }
} }
diff -r df721eb4cd55 src/state.js diff -r df721eb4cd55 src/state.js
--- a/src/state.js Sun Dec 16 04:39:00 2018 -0600 --- a/src/state.js Sun Dec 16 04:39:00 2018 -0600
+++ b/src/state.js Fri Jan 25 00:54:01 2019 +0100 +++ b/src/state.js Fri Jan 25 00:54:01 2019 +0100
@@ -104,7 +104,7 @@ @@ -104,7 +104,7 @@
} }
if (_expired.length > 0) { if (_expired.length > 0) {
- stateObj.expired = [..._expired]; - stateObj.expired = [..._expired];
+ stateObj.expired = []; + stateObj.expired = [];
} }
if (_prng !== null) { if (_prng !== null) {
diff -r df721eb4cd55 src/ui.js diff -r df721eb4cd55 src/ui.js
--- a/src/ui.js Sun Dec 16 04:39:00 2018 -0600 --- a/src/ui.js Sun Dec 16 04:39:00 2018 -0600
+++ b/src/ui.js Fri Jan 25 00:54:01 2019 +0100 +++ b/src/ui.js Fri Jan 25 00:54:01 2019 +0100
@@ -334,6 +334,7 @@ @@ -334,6 +334,7 @@
if (saves.slots[i]) { if (saves.slots[i]) {
// Add the load button. // Add the load button.
$tdLoad.append( $tdLoad.append(
+ createButton('save', 'ui-close', L10n.get('savesLabelSave'), i, Save.slots.save), + createButton('save', 'ui-close', L10n.get('savesLabelSave'), i, Save.slots.save),
createButton('load', 'ui-close', L10n.get('savesLabelLoad'), i, slot => { createButton('load', 'ui-close', L10n.get('savesLabelLoad'), i, slot => {
jQuery(document).one(':dialogclose', () => Save.slots.load(slot)); jQuery(document).one(':dialogclose', () => Save.slots.load(slot));
}) })
...@@ -623,3 +623,107 @@ div.tab button.active { ...@@ -623,3 +623,107 @@ div.tab button.active {
opacity: 1; opacity: 1;
} }
} }
/*:: Options Macro [stylesheet]*/
.optionMacro {
margin-top: 8px;
display: inline-block;
}
.optionDescription {
display: inline-block;
width: 500px;
margin-right: 10px;
line-height: 1.2;
text-align: right;
}
@media only screen and (max-width: 1200px) {
.optionDescription {
display: block;
width: unset;
}
.optionMacro {
margin-top: 30px;
}
}
.optionMacroOption {
border: #555 solid 0.5px;
border-top-width: 0;
vertical-align: top;
background: linear-gradient(transparent,#222);
-moz-user-select: none;
min-width: 79px; /* 80px - 1px for border */
display: inline-block;
text-align: center;
}
.optionComment {
vertical-align: top;
color: gray;
}
/* But don't add the | after the last one */
.optionMacroOption:last-child {
border-top-right-radius: 6px;
border-bottom-right-radius: 6px;
border-right-width: 0;
}
.optionMacroOption:first-child {
border-top-left-radius: 6px;
border-bottom-left-radius: 6px;
}
.optionMacroOption a {
padding: 0 10px;
box-sizing: border-box;
width: 100%;
display: block;
}
.optionMacroOption:hover {
background: linear-gradient(#2F2F2F,#111);
}
.optionMacroSelected {
background: linear-gradient(#2F2F2F,#111);
padding: 0 10px;
min-width: 80px;
cursor: pointer;
box-sizing: border-box;
}
.optionValue input {
padding: 3px;
background: linear-gradient(transparent,#222);
border: #555 solid 0.5px;
border-top-width: 0;
min-width: reset;
width: 140px;
}
.optionValue input:last-child {
border-top-right-radius: 6px;
border-bottom-right-radius: 6px;
border-right-width: 0;
}
.optionValue input:first-child {
border-top-left-radius: 6px;
border-bottom-left-radius: 6px;
}
.optionMacroSelected.optionMacroEnable {
color: rgb(230,255,230);
background-image: linear-gradient(rgba(0, 255,0, 0.12), transparent);
}
.optionMacroSelected.optionMacroDisable {
color: rgb(255,240,240);
background-image: linear-gradient(rgba(255, 100, 0, 0.2), transparent);
}
#!/bin/sh #!/bin/sh
x=bin/* #Packages required: MEGAcmd,minify,git. U=$1 P=$2 remtDir=$3 locDir=$4 repo=$5 mega-login $1 $2;echo 'New clone? 0:y 1:n 2:na';read Opt #Requirements:MEGAcmd,minify,git. U=$1 P=$2 rDir=$3 lDir=$4 repo=$5
echo 'New clone? 0:y 1:n 2:na';read Opt;clear;mega-login $U $P >/dev/null while true;do cd $4;gen=0
while true;do cd $4 2>/dev/null && if [ $? -eq 0 ];then cd $4;fi if [ $Opt == 0 ];then mkdir -p $4&&git clone -q --depth 1 $5 $4&&cd $4&&if [[ ! `mega-ls $3|cut -c29-32|paste -sd,` =~ `git log|head -1|cut -c8-11` ]];then gen=1;fi #arraryCheck:stackoverflow.com/a/15394738
if [ $Opt -eq 0 ];then A=[$(mega-ls $3/|cut -c 29-|sed s/.html//|paste -sd,"")];mkdir -p $4 && git clone -q --no-tags --depth 1 $5 $4 && cd $4 && V=$(git log -1|grep comm|cut -c 8-11);if [[ ! " ${A[@]} " =~ " ${V} " ]];then gen=1;fi #arraryCheck:stackoverflow.com/a/15394738 elif [[ $Opt > 0||$gen < 1 ]];then git fetch -q&&if [ `git rev-list ...origin --count` -gt 0 ];then git reset -q --hard&&git pull -q&&gen=1;fi ;fi #gitCheck:stackoverflow.com/a/17192101
elif [[ $Opt > 0||$gen < 1 ]];then git fetch -q;if [ `git rev-list HEAD...origin/pregmod-master --count` -gt 0 ];then git reset -q --hard HEAD && git pull -q && gen=1;fi ;fi #gitCheck:stackoverflow.com/a/17192101 if [[ $Opt > 1||$gen > 0 ]];then minify -rao $4 $4&&./compile --insane&&cd bin/&&rm FC-*;mv * FC-pregmod-`git log -1 --format=%cd --date=format:%m-%d-%Y-%H-%M`-`git log|head -1|cut -c8-11`.html&&mega-put -c * $3&&mega-rm $3`mega-ls $3|sort -r|tail -n +11`;fi
if [[ $Opt > 1||$gen > 0 ]];then rm $x 2>/dev/null;minify -rao $4 $4 && ./compile --insane >/dev/null && mv $x bin/FC-pregmod-$(git log -1 --format='%cd' --date='format:%d-%m-%Y-%H-%M')-$(git log -1|grep comm|cut -c 8-11).html && mega-put -c $x $3 && if [ `mega-ls $3|wc -l` -gt 10 ];then mega-rm $3$(mega-ls $3|sort -r|tail -n +11);fi ; fi Opt=-1;clear;sleep 15m;done
gen=0;Opt=-1;sleep 15m;done
\ No newline at end of file
...@@ -3,14 +3,4 @@ ...@@ -3,14 +3,4 @@
# #
src/art/ src/art/
src/gui/svgFilters.tw src/gui/svgFilters.tw
#
#excluded to reduce false positives until better solution:
src/pregmod/basenationalitiesControls.tw
src/pregmod/editGenetics.tw src/pregmod/editGenetics.tw
src/pregmod/widgets/bodySwapReaction.tw
src/uncategorized/costsBudget.tw
src/uncategorized/initRules.tw
src/uncategorized/slaveAssignmentsReport.tw
src/uncategorized/storyCaption.tw
src/cheats/
src/pregmod/customizeSlaveTrade.tw
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
#included to reduce false positives until better solution #included to reduce false positives until better solution
!-- !--
http://www.gnu.org/licenses/ http://www.gnu.org/licenses/
-400
#html tags #html tags
a;1 a;1
b;1 b;1
......
...@@ -12,6 +12,9 @@ import java.nio.file.Path; ...@@ -12,6 +12,9 @@ import java.nio.file.Path;
import java.nio.file.Paths; import java.nio.file.Paths;
import java.util.*; import java.util.*;
/**
* @author Arkerthan
*/
public class Main { public class Main {
public static TagSearchTree<Tag> htmlTags, twineTags; public static TagSearchTree<Tag> htmlTags, twineTags;
...@@ -22,6 +25,7 @@ public class Main { ...@@ -22,6 +25,7 @@ public class Main {
private static String[] excluded; private static String[] excluded;
public static void main(String[] args) { public static void main(String[] args) {
//setup //setup
setupExclude(); setupExclude();
setupHtmlTags(); setupHtmlTags();
...@@ -31,7 +35,7 @@ public class Main { ...@@ -31,7 +35,7 @@ public class Main {
//actual sanityCheck //actual sanityCheck
runSanityCheckInDirectory(workingDir, new File("src/")); runSanityCheckInDirectory(workingDir, new File("src/"));
//handle errors //output errors
for (SyntaxError e : for (SyntaxError e :
errors) { errors) {
System.out.println(e.getError()); System.out.println(e.getError());
...@@ -41,7 +45,7 @@ public class Main { ...@@ -41,7 +45,7 @@ public class Main {
/** /**
* Goes through the whole directory including subdirectories and runs * Goes through the whole directory including subdirectories and runs
* sanityCheck() on all .tw files * {@link Main#sanityCheck(Path)} on all .tw files
* *
* @param dir to be checked * @param dir to be checked
*/ */
...@@ -61,7 +65,7 @@ public class Main { ...@@ -61,7 +65,7 @@ public class Main {
} }
} catch (NullPointerException e) { } catch (NullPointerException e) {
e.printStackTrace(); e.printStackTrace();
System.err.println("Couldn't find directory " + currentFile); System.err.println("Couldn't read directory " + currentFile);
System.exit(-1); System.exit(-1);
} }
} }
...@@ -78,42 +82,33 @@ public class Main { ...@@ -78,42 +82,33 @@ public class Main {
Charset encoding = Charset.defaultCharset(); Charset encoding = Charset.defaultCharset();
if (!excluded(file.getPath())) { if (!excluded(file.getPath())) {
try { currentFile = file.getPath();
currentFile = file.getPath(); currentLine = 1;
currentLine = 1; stack = new Stack<>();
stack = new Stack<>();
//actually opening and reading the file
//actually opening and reading the file try (InputStream in = new FileInputStream(file);
try (InputStream in = new FileInputStream(file); Reader reader = new InputStreamReader(in, encoding);
Reader reader = new InputStreamReader(in, encoding); // buffer for efficiency
// buffer for efficiency Reader buffer = new BufferedReader(reader)) {
Reader buffer = new BufferedReader(reader)) { handleCharacters(buffer);
handleCharacters(buffer);
}
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace();
System.err.println("Couldn't read " + file); System.err.println("Couldn't read " + file);
} }
} }
} }
/** /**
* sets up the alphabetical search tree for fast access of HTML tags later * sets up a {@link TagSearchTree<Tag>} for fast access of HTML tags later
*/ */
private static void setupHtmlTags() { private static void setupHtmlTags() {
//load HTML tags into a list //load HTML tags into a list
List<Tag> TagsList = new LinkedList<>(); List<Tag> TagsList = loadTags("devTools/javaSanityCheck/htmlTags");
try {
Files.lines(new File("devTools/javaSanityCheck/htmlTags").toPath()).map(String::trim)
.filter(s -> !s.startsWith("#"))
.forEach(s -> TagsList.add(parseTag(s)));
} catch (IOException e) {
System.err.println("Couldn't read devTools/javaSanityCheck/htmlTags");
}
//turn List into alphabetical search tree //turn List into alphabetical search tree
try { try {
htmlTags = new TagSearchTree(TagsList); htmlTags = new TagSearchTree<>(TagsList);
} catch (ArrayIndexOutOfBoundsException e) { } catch (ArrayIndexOutOfBoundsException e) {
System.err.println("Illegal Character in devTools/javaSanityCheck/htmlTags"); System.err.println("Illegal Character in devTools/javaSanityCheck/htmlTags");
System.exit(-1); System.exit(-1);
...@@ -121,29 +116,39 @@ public class Main { ...@@ -121,29 +116,39 @@ public class Main {
} }
/** /**
* sets up the alphabetical search tree for fast access of twine tags later * sets up a {@link TagSearchTree<Tag>} for fast access of twine tags later
*/ */
private static void setupTwineTags() { private static void setupTwineTags() {
//load twine tags into a list //load twine tags into a list
List<Tag> TagsList = new LinkedList<>(); List tagsList = loadTags("devTools/javaSanityCheck/twineTags");
try {
Files.lines(new File("devTools/javaSanityCheck/twineTags").toPath()).map(String::trim)
.filter(s -> !s.startsWith("#"))
.forEach(s -> TagsList.add(parseTag(s)));
} catch (IOException e) {
System.err.println("Couldn't read devTools/javaSanityCheck/twineTags");
}
//turn List into alphabetical search tree //turn List into alphabetical search tree
try { try {
twineTags = new TagSearchTree(TagsList); twineTags = new TagSearchTree<>(tagsList);
} catch (ArrayIndexOutOfBoundsException e) { } catch (ArrayIndexOutOfBoundsException e) {
System.err.println("Illegal Character in devTools/javaSanityCheck/twineTags"); System.err.println("Illegal Character in devTools/javaSanityCheck/twineTags");
System.exit(-1); System.exit(-1);
} }
} }
/**
* Loads a list of tags from a file
*
* @param filePath file to load tags from
* @return loaded tags
*/
private static List<Tag> loadTags(String filePath) {
List<Tag> tagsList = new LinkedList<>();
try {
Files.lines(new File(filePath).toPath()).map(String::trim)
.filter(s -> !s.startsWith("#"))
.forEach(s -> tagsList.add(parseTag(s)));
} catch (IOException e) {
System.err.println("Couldn't read " + filePath);
}
return tagsList;
}
/** /**
* Turns a string into a Tag * Turns a string into a Tag
* ";1" at the end of the String indicates that the tag needs to be closed later * ";1" at the end of the String indicates that the tag needs to be closed later
...@@ -160,7 +165,7 @@ public class Main { ...@@ -160,7 +165,7 @@ public class Main {
} }
/** /**
* sets up the excluded array. * sets up the excluded files array.
*/ */
private static void setupExclude() { private static void setupExclude() {
//load excluded files //load excluded files
...@@ -173,7 +178,7 @@ public class Main { ...@@ -173,7 +178,7 @@ public class Main {
System.err.println("Couldn't read devTools/javaSanityCheck/excluded"); System.err.println("Couldn't read devTools/javaSanityCheck/excluded");
} }
//turn excluded files into an array and change them to windows style if needed //turn excluded files into an array and change path to windows style if needed
if (isWindows()) { if (isWindows()) {
excluded = new String[excludedList.size()]; excluded = new String[excludedList.size()];
int i = 0; int i = 0;
...@@ -252,33 +257,37 @@ public class Main { ...@@ -252,33 +257,37 @@ public class Main {
stack.pop(); stack.pop();
return; return;
} }
//3 means the Element is complete and part of a two tag system //3 means the Element is complete and part of a two or more tag system
if (change == 3) { if (change == 3) {
//remove the topmost element from stack since it is complete //remove the topmost element from stack since it is complete
KnownElement k = stack.pop().getKnownElement(); KnownElement k = stack.pop().getKnownElement();
/*if (k.isOpening()) { //if KnownElement k is closing another element, check if there is one and remove it
stack.push(k);
} else */
if (k.isClosing()) { if (k.isClosing()) {
if (stack.empty()) { if (stack.empty()) { //there are no open elements at all
addError(new SyntaxError("Closed tag " + k.getShortDescription() + " without having any open tags.", -2)); addError(new SyntaxError("Closed tag " + k.getShortDescription() + " without " +
"having any open tags.", -2));
} else if (stack.peek() instanceof KnownElement) { } else if (stack.peek() instanceof KnownElement) {
//get opening tag
KnownElement kFirst = (KnownElement) stack.pop(); KnownElement kFirst = (KnownElement) stack.pop();
//check if closing element matches the opening element
if (!kFirst.isMatchingElement(k)) { if (!kFirst.isMatchingElement(k)) {
addError(new SyntaxError("Opening tag " + kFirst.getShortDescription() + addError(new SyntaxError("Opening tag " + kFirst.getShortDescription() +
" does not match closing tag " + k.getShortDescription() + ".", -2)); " does not match closing tag " + k.getShortDescription() + ".", -2));
} }
//stack.pop();
} else { } else {
//There closing tag inside another not Known element: <div </html>
addError(new SyntaxError("Closing tag " + k.getShortDescription() + " inside " + addError(new SyntaxError("Closing tag " + k.getShortDescription() + " inside " +
"another tag: " + stack.peek().getShortDescription(), -2, true)); "another tag " + stack.peek().getShortDescription() + " without opening first.",
-2, true));
} }
} }
//check if the element needs to be closed by another
if (k.isOpening()) { if (k.isOpening()) {
stack.push(k); stack.push(k);
} }
return; return;
} }
//means the element couldn't do anything with it and is finished
if (change == 4) { if (change == 4) {
stack.pop(); stack.pop();
} else { } else {
...@@ -291,7 +300,7 @@ public class Main { ...@@ -291,7 +300,7 @@ public class Main {
//innermost element was uninterested, trying to find matching element //innermost element was uninterested, trying to find matching element
switch (c) { switch (c) {
//case '@': //case '@':
// stack.push(new AtElement(currentLine, currentPosition)); //stack.push(new AtElement(currentLine, currentPosition));
//break; //break;
case '<': case '<':
stack.push(new AngleBracketElement(currentLine, currentPosition)); stack.push(new AngleBracketElement(currentLine, currentPosition));
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment