deprecate old projects & reduce CI workload

This commit is contained in:
2023-02-18 16:24:20 -07:00
parent c5002c48bc
commit e1f306a92e
147 changed files with 4 additions and 9 deletions

View File

@@ -0,0 +1 @@
export

View File

@@ -0,0 +1,5 @@
{
"recommendations": [
"openfl.lime-vscode-extension"
]
}

View File

@@ -0,0 +1,21 @@
{
"version": "0.2.0",
"configurations": [
{
"name": "Build + Debug",
"type": "lime",
"request": "launch"
},
{
"name": "Debug",
"type": "lime",
"request": "launch",
"preLaunchTask": null
},
{
"name": "Macro",
"type": "haxe-eval",
"request": "launch"
}
]
}

View File

@@ -0,0 +1,13 @@
{
"search.exclude": {
"export/**/*.hx": true
},
"[haxe]": {
"editor.formatOnSave": true,
"editor.formatOnPaste": true,
"editor.codeActionsOnSave": {
"source.sortImports": true
}
},
"haxe.enableExtendedIndentation": true
}

View File

@@ -0,0 +1,13 @@
{
"version": "2.0.0",
"tasks": [
{
"type": "lime",
"command": "test",
"group": {
"kind": "build",
"isDefault": true
}
}
]
}

View File

@@ -0,0 +1,86 @@
<?xml version="1.0" encoding="utf-8"?>
<project>
<!-- _________________________ Application Settings _________________________ -->
<app title="Handloose" file="Handloose" main="Main" version="0.0.1" company="HaxeFlixel" />
<!--The flixel preloader is not accurate in Chrome. You can use it regularly if you embed the swf into a html file
or you can set the actual size of your file manually at "FlxPreloaderBase-onUpdate-bytesTotal"-->
<app preloader="flixel.system.FlxPreloader" />
<!--Minimum without FLX_NO_GAMEPAD: 11.8, without FLX_NO_NATIVE_CURSOR: 11.2-->
<set name="SWF_VERSION" value="11.8" />
<!-- ____________________________ Window Settings ___________________________ -->
<!--These window settings apply to all targets-->
<window width="1280" height="720" fps="60" background="#000000" hardware="true" vsync="false" />
<!--HTML5-specific-->
<window if="html5" resizable="false" />
<!--Desktop-specific-->
<window if="desktop" orientation="landscape" fullscreen="false" resizable="true" />
<!--Mobile-specific-->
<window if="mobile" orientation="landscape" fullscreen="true" width="0" height="0" />
<!-- _____________________________ Path Settings ____________________________ -->
<set name="BUILD_DIR" value="export" />
<classpath name="source" />
<!-- _______________________________ Libraries ______________________________ -->
<haxelib name="flixel" />
<haxelib name="kiss" />
<!--In case you want to use the addons package-->
<!--<haxelib name="flixel-addons" />-->
<!--In case you want to use the ui package-->
<!--<haxelib name="flixel-ui" />-->
<!--In case you want to use nape with flixel-->
<!--<haxelib name="nape-haxe4" />-->
<!-- ______________________________ Haxedefines _____________________________ -->
<!-- Uncomment these and change the values to pre-compile character frequencies: -->
<!--<haxedef name="LEARN_FROM" value="path/to/text/folder"/>-->
<!--<haxedef name="LEARN_FROM_EXT" value="txt,markdown,etc"/>-->
<!--Enable the Flixel core recording system-->
<!--<haxedef name="FLX_RECORD" />-->
<!--Disable the right and middle mouse buttons-->
<!--<haxedef name="FLX_NO_MOUSE_ADVANCED" />-->
<!--Disable the native cursor API on Flash-->
<!--<haxedef name="FLX_NO_NATIVE_CURSOR" />-->
<!--Optimise inputs, be careful you will get null errors if you don't use conditionals in your game-->
<haxedef name="FLX_NO_MOUSE" if="mobile" />
<haxedef name="FLX_NO_KEYBOARD" if="mobile" />
<haxedef name="FLX_NO_TOUCH" if="desktop" />
<!--<haxedef name="FLX_NO_GAMEPAD" />-->
<!--Disable the Flixel core sound tray-->
<!--<haxedef name="FLX_NO_SOUND_TRAY" />-->
<!--Disable the Flixel sound management code-->
<!--<haxedef name="FLX_NO_SOUND_SYSTEM" />-->
<!--Disable the Flixel core focus lost screen-->
<!--<haxedef name="FLX_NO_FOCUS_LOST_SCREEN" />-->
<!--Disable the Flixel core debugger. Automatically gets set whenever you compile in release mode!-->
<haxedef name="FLX_NO_DEBUG" unless="debug" />
<!--Enable this for Nape release builds for a serious peformance improvement-->
<haxedef name="NAPE_RELEASE_BUILD" unless="debug" />
<!-- _________________________________ Custom _______________________________ -->
<!--Place custom nodes like icons here (higher priority to override the HaxeFlixel icon)-->
</project>

View File

@@ -0,0 +1,15 @@
{
"lineEnds": {
"leftCurly": "both",
"rightCurly": "both",
"objectLiteralCurly": {
"leftCurly": "after"
}
},
"sameLine": {
"ifElse": "next",
"doWhile": "next",
"tryBody": "next",
"tryCatch": "next"
}
}

View File

@@ -0,0 +1,9 @@
package;
import kiss.Prelude;
import kiss.List;
import flixel.FlxSprite;
import TypingState;
@:build(kiss.Kiss.build())
class ActionSprite extends FlxSprite {}

View File

@@ -0,0 +1,3 @@
(defNew [&prop :Void->Void action
&prop :ArrowDir dir]
(super))

View File

@@ -0,0 +1,16 @@
package;
import kiss.Prelude;
import kiss.List;
import sys.io.File;
import sys.FileSystem;
import flixel.math.FlxRandom;
import haxe.io.Path;
typedef ArrowStuff = {
text:String,
action:Void->Void
};
@:build(kiss.Kiss.build())
class DocumentModel {}

View File

@@ -0,0 +1,58 @@
(defNew [&prop :String path]
(when (FileSystem.exists path) (set content (File.getContent path)))
(type "") // If the file can't be written to, throw the error right away
(learnAllFrequencies)
~charFrequencies)
(prop &mut :String content "")
(method :Void type [:String str]
(+= content str)
(File.saveContent path content))
// TODO make this a map of String,DateTime and re-learn from files that were modified more recently
(savedVar :Map<String,Bool> filesLearnedFrom (new Map))
(savedVar :Map<String,Map<String,Float>> charFrequencies (new Map))
(savedVar :Map<String,Map<String,Float>> wordFrequencies (new Map))
(method incFrequency [:Map<String,Map<String,Float>> m :String c :String following]
(let [&mut weight 1.0]
(when c
(when (= c "\r") (set c "\n"))
(when (= c following " ") (set c "\t") (set weight 0.25))
(unless (m.exists following) (dictSet m following (new Map)))
(let [followingMap (dictGet m following)]
(dictSet followingMap c (+ weight (or (dictGet followingMap c) 0)))))))
(method learnAllFrequencies []
// Use files with the same extension in the current working directory to determine letter frequencies
(withMutProperties [filesLearnedFrom]
(walkDirectory "" (FileSystem.absolutePath "")
->file (when (= (Path.extension file) (Path.extension path))
(unless (filesLearnedFrom.exists path)
(print "learning from $file")
(learnFrequencies (File.getContent file))
(dictSet filesLearnedFrom path true))))))
(method learnFrequencies [:String str]
(let [chars (str.split "")]
(when chars
(withMutProperties [charFrequencies wordFrequencies]
(incFrequency charFrequencies (first chars) "")
(doFor [following c] (pairs chars)
(incFrequency charFrequencies c following)))
// TODO learn word frequencies
)))
(prop :FlxRandom r (new FlxRandom))
(var ANY_CHANCE 25) // percent
(method :ArrowStuff generateArrowStuff []
// TODO also generate word arrows if lastChar is a space or the word in progress is a substring of a common word
(let [lastChar (substr content -1)
charFreq (dictGet charFrequencies lastChar)
chars []
:Array<Float> weights []]
(doFor =>c weight charFreq
(chars.push c)
(weights.push weight))
(let [c (r.getObject chars (if (r.bool ANY_CHANCE) null weights))]
(object text c action ->(type c)))))

View File

@@ -0,0 +1,16 @@
package;
import flixel.FlxG;
import flixel.FlxGame;
import openfl.display.Sprite;
class Main extends Sprite
{
public function new()
{
super();
addChild(new FlxGame(0, 0, TypingState, 60, 60, true));
var t:TypingState = cast FlxG.state;
t.setModel(new DocumentModel(Sys.args()[0]));
}
}

View File

@@ -0,0 +1,62 @@
package;
import flixel.FlxG;
import flixel.FlxState;
import flixel.FlxSprite;
import flixel.util.FlxColor;
import flixel.util.FlxTimer;
import flixel.group.FlxGroup;
import flixel.input.gamepad.FlxGamepad;
import flixel.text.FlxText;
import flixel.tweens.FlxTween;
import haxe.ds.Option;
import kiss.Prelude;
import kiss.List;
using flixel.util.FlxSpriteUtil;
// In DDR order:
enum ArrowDir
{
Left;
Down;
Up;
Right;
}
@:build(kiss.Kiss.build())
class TypingState extends FlxState
{
function makeCircleSprite(text:String, x:Int, y:Int):FlxSprite
{
var spr = new FlxSprite();
spr.makeGraphic(100, 100, FlxColor.TRANSPARENT, true);
FlxSpriteUtil.beginDraw(FlxColor.WHITE);
spr.drawCircle();
var text = new FlxText(text, 24);
text.color = FlxColor.BLACK;
spr.stamp(text, 50 - Math.floor(text.width / 2), 50 - Math.floor(text.height / 2));
spr.x = x;
spr.y = y;
return spr;
}
function getFirstInputId():Option<Int> {
// Important: can be null if there's no active gamepad yet!
var gamepad:FlxGamepad = FlxG.gamepads.lastActive;
if (gamepad != null)
{
var firstGamepadId = gamepad.firstJustPressedRawID();
if (firstGamepadId != -1) {
return Some(firstGamepadId);
}
}
var firstKeyId = FlxG.keys.firstJustPressed();
if (firstKeyId != -1) {
return Some(firstKeyId);
} else {
return None;
}
}
}

View File

@@ -0,0 +1,150 @@
(var SPRITE_SPACING 20)
(var SPRITE_SIZE 100)
(var TEXT_SIZE 24)
(prop &mut :FlxText docText null)
(method &override :Void create []
#{
super.create();
var background = new FlxSprite();
background.makeGraphic(1280, 720, FlxColor.BLACK);
// background.x = 0;
// background.y = 0;
FlxSpriteUtil.beginDraw(FlxColor.WHITE);
var x = SPRITE_SPACING;
var y = FlxG.height - SPRITE_SIZE - SPRITE_SPACING;
// Split the screen into text area and dance area:
var splitX = SPRITE_SPACING * 5 + SPRITE_SIZE * 4;
background.drawLine(splitX, 0, splitX, FlxG.height);
docText = new FlxText(splitX, 0, "", TEXT_SIZE);
docText.setFormat(null, 8, FlxColor.WHITE);
add(background);
add(docText);
// this is actually just distracting:
// Split the left side into upper/lower:
//background.drawLine(0, FlxG.height - SPRITE_SIZE - SPRITE_SPACING * 2, splitX, FlxG.height - SPRITE_SIZE - SPRITE_SPACING * 2);
/*
makeTriangleSprite(Left, "", y);
makeTriangleSprite(Down, "", y);
makeTriangleSprite(Up, "", y);
makeTriangleSprite(Right, "", y);
*/
add(actionSprites);
}#)
(prop :Map<Int,ArrowDir> inputCodes (new Map))
(var DIR_ORDER [ Left Down Up Right ])
(prop &mut :FlxText instructionText null)
(method &override :Void update [:Float elapsed]
(super.update elapsed)
(let [mappedCodes (count inputCodes)
nextToMap (nth DIR_ORDER mappedCodes)]
(if (= DIR_ORDER.length mappedCodes)
// Handle an arrow press
{
(set instructionText.text "")
(unless timer
(set timer (new FlxTimer))
(let [&mut i 0]
(timer.start ARROW_DELAY ->_ {
#{
var stuff = _model.generateArrowStuff();
makeTriangleSprite(DIR_ORDER[i++ % DIR_ORDER.length], stuff.text, -SPRITE_SIZE, stuff.action);
}# } 0)))
(whenLet [(Some id) (getFirstInputId)
dir (dictGet inputCodes id)]
(let [&mut :ActionSprite lowestMatching null
&mut :Float highestY -SPRITE_SIZE-1]
(actionSprites.forEachAlive
->spr (when (= dir spr.dir)
(when (> spr.y highestY)
(set highestY spr.y)
(set lowestMatching spr))))
(when lowestMatching
(lowestMatching.action)
(updateDocText)
(lowestMatching.kill))))
}
// Prompt to map the arrows
{
(unless instructionText
(set instructionText (new FlxText "" TEXT_SIZE))
(add instructionText))
(set instructionText.text "Press $nextToMap")
(instructionText.screenCenter)
(whenLet [(Some id) (getFirstInputId)]
(dictSet inputCodes id nextToMap))
})))
(method updateDocText []
(set docText.text (StringTools.replace _model.content "\t" " ")))
(prop :FlxTypedGroup<ActionSprite> actionSprites (new FlxTypedGroup))
(prop &mut :DocumentModel _model null)
(prop &mut :FlxTimer timer null)
(var ARROW_DELAY 0.25)
(method setModel [:DocumentModel m]
(set _model m)
(updateDocText))
(method :FlxSprite makeTriangleSprite [:ArrowDir dir :String text :Int y &opt :Void->Void action]
#{
var spr = new ActionSprite(action, dir);
spr.makeGraphic(SPRITE_SIZE, SPRITE_SIZE, FlxColor.TRANSPARENT, true);
FlxSpriteUtil.beginDraw(FlxColor.WHITE);
spr.drawTriangle(0, 0, SPRITE_SIZE);
spr.angle = switch (dir)
{
case Left:
-90;
case Down:
180;
case Up:
0;
case Right:
90;
};
text = switch (text) {
case "\n": "<newline>";
case "\r": "<bad newline>";
case " ": "<space>";
case "\t": "<tab>";
default: text;
};
var ftext = new FlxText(text, TEXT_SIZE);
ftext.angle = -spr.angle;
ftext.color = FlxColor.BLACK;
if (text.length > 1) {
ftext.size = 12;
}
spr.stamp(ftext, Math.floor(SPRITE_SIZE/2) - Math.floor(ftext.width / 2), Math.floor(SPRITE_SIZE/2) - Math.floor(ftext.height / 2));
spr.x = SPRITE_SPACING + DIR_ORDER.indexOf(dir) * (SPRITE_SIZE + SPRITE_SPACING);
spr.y = y;
if (action != null) {
actionSprites.add(spr);
FlxTween.linearMotion(spr, spr.x, spr.y, spr.x, FlxG.height, 200, false, {
onComplete: (_) -> {
spr.kill();
}
});
} else {
add(spr);
}
return spr;
}#)