Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add checkstyle and hxformat configs #4

Merged
merged 2 commits into from Sep 15, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
198 changes: 192 additions & 6 deletions checkstyle.json
@@ -1,8 +1,194 @@
{
"type": "WhitespaceAfter",
"props": {
"tokens": [
":"
]
}
"defaultSeverity": "INFO",
"checks": [
{
"type": "UnusedLocalVar"
},
{
"type": "UnusedImport",
"props": {
"severity": "WARNING"
}
},
{
"type": "SimplifyBooleanExpression",
"props": {
"severity": "ERROR"
}
},
{
"type": "SimplifyBooleanReturn",
"props": {
"severity": "ERROR"
}
},
{
"type": "ArrayLiteral",
"props": {
"severity": "ERROR"
}
},
{
"type": "StringLiteral",
"props": {
"policy": "onlySingle",
"allowException": false,
"severity": "ERROR"
}
},
{
"type": "NeedBraces",
"props": {
"severity": "WARNING",
"allowSingleLineStatement": false,
"tokens": [
"FOR",
"IF",
"ELSE_IF",
"WHILE",
"DO_WHILE"
]
}
},
{
"type": "EmptyLines",
"props": {
"max": 1,
"allowEmptyLineAfterSingleLineComment": false,
"requireEmptyLineAfterClass": false,
"requireEmptyLineAfterPackage": true,
"requireEmptyLineAfterAbstract": false,
"requireEmptyLineAfterInterface": false
}
},
{
"type": "MethodLength",
"props": {
"severity": "ERROR",
"max": 50,
"ignoreEmptyLines": true
}
},
{
"type": "UnnecessaryConstructor",
"props": {
"severity": "ERROR"
}
},
{
"type": "ParameterNumber",
"props": {
"severity": "INFO",
"max": 5,
"ignoreOverriddenMethods": false
}
},
{
"type": "FileLength",
"props": {
"severity": "WARNING",
"max": 1000
}
},
{
"type": "Indentation",
"props": {
"severity": "INFO",
"character": " ",
"ignoreConditionals": false,
"ignoreComments": false,
"conditionalPolicy": "aligned",
"wrapPolicy": "larger"
}
},
{
"type": "IndentationCharacter",
"props": {
"character": "space"
}
},
{
"type": "ConditionalCompilation",
"props": {
"policy": "aligned",
"allowSingleline": true,
"severity": "INFO"
}
},
{
"type": "ConstantName",
"props": {
"severity": "ERROR",
"format": "^[A-Z][A-Z0-9]*(_[A-Z0-9]+)*$",
"tokens": [
"INLINE"
]
}
},
{
"type": "DefaultComesLast",
"props": {
"severity": "WARNING"
}
},
{
"type": "MultipleVariableDeclarations",
"props": {
"severity": "WARNING"
}
},
{
"type": "Spacing",
"props": {
"severity": "INFO",
"spaceIfCondition": "should",
"spaceForLoop": "should",
"spaceWhileLoop": "should",
"spaceSwitchCase": "should",
"spaceCatch": "should",
"spaceAroundBinop": true,
"noSpaceAroundUnop": true,
"ignoreRangeOperator": true
}
},
{
"type": "WhitespaceAround",
"props": {
"tokens": [
"=",
"+",
"-",
"*",
"/",
"%",
">",
"<",
">=",
"<=",
"==",
"!=",
"&",
"|",
"^",
"&&",
"||",
"<<",
">>",
">>>",
"+=",
"-=",
"*=",
"/=",
"%=",
"<<=",
">>=",
">>>=",
"|=",
"&=",
"^=",
"=>"
]
}
}
]
}
61 changes: 44 additions & 17 deletions hxformat.json
@@ -1,24 +1,51 @@
{
"wrapping": {
"arrayMatrixWrap": "matrixWrapWithAlign",
"arrayWrap": {
"defaultWrap": "fillLine",
"defaultLocation": "afterLast"
},
"maxLineLength": 80
},
"lineEnds": {
"leftCurly": "after",
"emptyCurly": "break"
"whitespace": {
"typeHintColonPolicy": "after",
"colonPolicy": "after",
"caseColonPolicy": "after",
"objectFieldColonPolicy": "after",
"bracesConfig": {
"objectLiteralBraces": {
"openingPolicy": "after",
"closingPolicy": "before"
},
"blockBraces": {
"removeInnerWhenEmpty": true,
"closingPolicy": "before",
"openingPolicy": "around"
}
}
},
"indentation": {
"character": " ",
"tabWidth": 2
"character": " "
},
"whitespace": {
"typeHintColonPolicy": "after"
"wrapping": {
"maxLineLength": 120,
"callParameter": {
"rules": [
{
"type": "onePerLine",
"conditions": [
{
"cond": "lineLength >= n",
"value": 95
},
{
"cond": "anyItemLength >= n",
"value": 10
},
{
"cond": "itemCount >= n",
"value": 6
}
]
}
]
}
},
"sameLine": {
"functionBody": "keep"
"lineEnds": {
"blockCurly": {
"rightCurly": "after"
}
}
}
95 changes: 47 additions & 48 deletions src/TestPlugin.hx
Expand Up @@ -10,68 +10,67 @@ using core.StringExtensions;
using Std;

class TestPlugin {
public static var textSpeed: Int = 2;
public static var textSpeed: Int = 2;

public static function main() {
trace(Sprite_Base);
// Plugin parameters can be include here as an internal call.
// MacroTools.includeJsLib("./src/TestPluginParams.js");
public static function main() {
trace(Sprite_Base);

var parameters: Any = PluginManager.parameters("TestPlugin");
textSpeed = Fn.getByArrSyntax(parameters, "Text Speed");
trace(textSpeed);
// Plugin parameters can be include here as an internal call.
// MacroTools.includeJsLib("./src/TestPluginParams.js");
var parameters: Any = PluginManager.parameters("TestPlugin");
textSpeed = Fn.getByArrSyntax(parameters, "Text Speed");
trace(textSpeed);

var newWinMsg = Fn.renameClass(Window_Message, MessageWinNew);
}
var newWinMsg = Fn.renameClass(Window_Message, MessageWinNew);
}
}

class MessageWinNew extends Window_Message {
public var activeTextSpeed: Int;
public var originalTextSpeed: Int;
public var activeTextSpeed: Int;
public var originalTextSpeed: Int;

public function new(x, y, width, height) {
super(x, y, width, height);
this.originalTextSpeed = TestPlugin.textSpeed;
this.activeTextSpeed = TestPlugin.textSpeed;
}
public function new(x, y, width, height) {
super(x, y, width, height);
this.originalTextSpeed = TestPlugin.textSpeed;
this.activeTextSpeed = TestPlugin.textSpeed;
}

public function updateTextSpeed(value) {
this.activeTextSpeed = value;
}
public function updateTextSpeed(value) {
this.activeTextSpeed = value;
}

public override function processEscapeCharacter(code: String,
textState: String) {
switch (code) {
case '$':
this._goldWindow.open();
case '.':
this.startWait(15);
case '!':
this.startPause();
public override function processEscapeCharacter(code: String, textState: String) {
switch (code) {
case '$':
this._goldWindow.open();
case '.':
this.startWait(15);
case '!':
this.startPause();

case '>':
this._lineShowFast = true;
case '>':
this._lineShowFast = true;

case '<':
this._lineShowFast = false;
case '<':
this._lineShowFast = false;

case '^':
this._pauseSkip = true;
case '^':
this._pauseSkip = true;

case 'TS':
this.updateTextSpeed(this.obtainEscapeParam(textState).int());
case _:
super.processEscapeCharacter(code, textState);
case 'TS':
this.updateTextSpeed(this.obtainEscapeParam(textState).int());
case _:
super.processEscapeCharacter(code, textState);
}
}
}

public override function processNormalCharacter(textState: String) {
super.processNormalCharacter(textState);
this.startWait(this.activeTextSpeed);
}
public override function processNormalCharacter(textState: String) {
super.processNormalCharacter(textState);
this.startWait(this.activeTextSpeed);
}

public override function terminateMessage() {
this.activeTextSpeed = this.originalTextSpeed;
super.terminateMessage();
}
public override function terminateMessage() {
this.activeTextSpeed = this.originalTextSpeed;
super.terminateMessage();
}
}