Skip to content
This repository has been archived by the owner on Jun 25, 2024. It is now read-only.

Commit

Permalink
AHHHHHHHHHHHHHHHHHHHH
Browse files Browse the repository at this point in the history
  • Loading branch information
TheDrawingCoder-Gamer committed Feb 16, 2021
1 parent fd464c4 commit 8f4f4f8
Show file tree
Hide file tree
Showing 10 changed files with 271 additions and 59 deletions.
41 changes: 41 additions & 0 deletions assets/data/freeplaySongJson.jsonc
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
[
{
"name": "Base Game",
"songs": [
// we use tjson so we can do comments and do some incorrect things
// the reason we use tjson is because json is hard
// The category screen won't show up unless there are more than 1 categories
"Tutorial",
"Bopeebo",
"Fresh",
"Dadbattle",
"Spookeez",
"South",
"Monster",
"Pico",
"Philly",
"Blammed",
"Satin-Panties",
"High",
"Milf",
"Cocoa",
"Eggnog",
"Winter-Horrorland",
"Senpai",
"Roses",
"Thorns"
]
},
// trailing commas don't matter with tjson
// visual studio code is just pissy
/*
uncomment this for an example
{
"name": "Custom 1",
"songs": [
"Bopeebo",
"Fresh",
]
},
*/
]
38 changes: 0 additions & 38 deletions assets/data/freeplaySongJson.yaml

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
{
# valid json is valid yaml so you can just rename your file
"template": {
"like": "bf",
"icons": [0,1]
Expand Down
10 changes: 5 additions & 5 deletions source/CategoryState.hx
Original file line number Diff line number Diff line change
Expand Up @@ -37,16 +37,16 @@ class CategoryState extends MusicBeatState
override function create()
{
// it's a js file to make syntax highlighting acceptable
var epicCategoryJs:Array<Dynamic> = Yaml.parse(Assets.getText('assets/data/freeplaySongJson.yaml'));
var epicCategoryJs:Array<Dynamic> = CoolUtil.parseJson(Assets.getText('assets/data/freeplaySongJson.jsonc'));
if (epicCategoryJs.length > 1) {
for (category in epicCategoryJs) {
categories.push(category.get("name"));
categorySongs.push(category.get("songs"));
categories.push(category.name);
categorySongs.push(category.songs);
}
} else {
// just set freeplay states songs to the only category
trace(epicCategoryJs[0].get("songs"));
FreeplayState.currentSongList = epicCategoryJs[0].get("songs");
trace(epicCategoryJs[0].songs);
FreeplayState.currentSongList = epicCategoryJs[0].songs;
FlxG.switchState(new FreeplayState());
}

Expand Down
10 changes: 5 additions & 5 deletions source/Character.hx
Original file line number Diff line number Diff line change
Expand Up @@ -546,15 +546,15 @@ class Character extends FlxSprite
var charJson:Dynamic = null;
var isError:Bool = false;
try {
charJson = Yaml.parse(Assets.getText('assets/images/custom_chars/custom_chars.yaml'));
charJson = CoolUtil.parseJson(Assets.getText('assets/images/custom_chars/custom_chars.jsonc'));
} catch (exception) {
// uh oh someone messed up their json
Application.current.window.alert("Hey! You messed up your custom_chars.yaml. Your game won't crash but it will load bf. "+exception, "Alert");
Application.current.window.alert("Hey! You messed up your custom_chars.jsonc. Your game won't crash but it will load bf. "+exception, "Alert");
isError = true;
}
if (!isError) {
// use assets, as it is less laggy
var animJson = File.getContent("assets/images/custom_chars/"+charJson.get(curCharacter).get("like")+".json");
var animJson = File.getContent("assets/images/custom_chars/"+Reflect.field(charJson,curCharacter).like+".json");
var parsedAnimJson:Dynamic = CoolUtil.parseJson(animJson);


Expand Down Expand Up @@ -918,8 +918,8 @@ class Character extends FlxSprite
animOffsets[name] = [x, y];
}
public static function getAnimJson(char:String) {
var charJson = Yaml.parse(Assets.getText('assets/images/custom_chars/custom_chars.yaml'));
var animJson = CoolUtil.parseJson(File.getContent('assets/images/custom_chars/'+charJson.get(char).get("like") + '.json'));
var charJson = CoolUtil.parseJson(Assets.getText('assets/images/custom_chars/custom_chars.jsonc'));
var animJson = CoolUtil.parseJson(File.getContent('assets/images/custom_chars/'+Reflect.field(charJson,char).like + '.json'));
return animJson;
}
}
4 changes: 2 additions & 2 deletions source/GameOverSubstate.hx
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@ class GameOverSubstate extends MusicBeatSubstate
}
var characterList = Assets.getText('assets/data/characterList.txt');
if (!StringTools.contains(characterList, p1)) {
var parsedCharJson:Dynamic = Yaml.parse(Assets.getText('assets/images/custom_chars/custom_chars.yaml'));
var parsedCharJson:Dynamic = CoolUtil.parseJson(Assets.getText('assets/images/custom_chars/custom_chars.jsonc'));
//another CTRL+C CTRL+V ritual
var unparsedAnimJson = File.getContent("assets/images/custom_chars/"+parsedCharJson.get(p1).get("like")+".json"); //it might keep throwing an error if i dont do this
var unparsedAnimJson = File.getContent("assets/images/custom_chars/"+Reflect.field(parsedCharJson,p1).like+".json"); //it might keep throwing an error if i dont do this
var parsedAnimJson = CoolUtil.parseJson(unparsedAnimJson);
switch (parsedAnimJson.like) {
case "bf":
Expand Down
6 changes: 3 additions & 3 deletions source/HealthIcon.hx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class HealthIcon extends FlxSprite
{
super();
#if sys
var charJson:Dynamic = Yaml.parse(File.getContent("assets/images/custom_chars/custom_chars.yaml"));
var charJson:Dynamic = CoolUtil.parseJson(File.getContent("assets/images/custom_chars/custom_chars.jsonc"));
#end
antialiasing = true;
switch (char) {
Expand Down Expand Up @@ -87,10 +87,10 @@ class HealthIcon extends FlxSprite
if (FileSystem.exists('assets/images/custom_chars/'+char+"/icons.png")) {
var rawPic:BitmapData = BitmapData.fromFile('assets/images/custom_chars/'+char+"/icons.png");
loadGraphic(rawPic, true, 150, 150);
animation.add('icon', charJson.get(char).get("icons"), false, isPlayer);
animation.add('icon', Reflect.field(charJson,char).icons, false, isPlayer);
} else {
loadGraphic('assets/images/iconGrid.png', true, 150, 150);
animation.add('icon', charJson.get(char).get("icons"), false, isPlayer);
animation.add('icon', Reflect.field(charJson,char).icons, false, isPlayer);
}
}
animation.play('icon');
Expand Down
188 changes: 188 additions & 0 deletions source/NewCharacterState.hx
Original file line number Diff line number Diff line change
@@ -0,0 +1,188 @@
package;

import flash.text.TextField;
import flixel.FlxG;
import flixel.FlxSprite;
import flixel.addons.display.FlxGridOverlay;
import flixel.group.FlxGroup.FlxTypedGroup;
import flixel.math.FlxMath;
import flixel.text.FlxText;
import flixel.util.FlxColor;
import lime.utils.Assets;
import DifficultyIcons;
import flixel.addons.ui.FlxInputText;
import flixel.addons.ui.FlxUI9SliceSprite;
import flixel.addons.ui.FlxUI;
import flixel.addons.ui.FlxUICheckBox;
import flixel.addons.ui.FlxUIDropDownMenu;
import flixel.addons.ui.FlxUIInputText;
import flixel.addons.ui.FlxUINumericStepper;
import flixel.ui.FlxButton;
import flixel.ui.FlxSpriteButton;
import flixel.addons.ui.FlxUITabMenu;
import lime.system.System;
#if sys
import sys.io.File;
import haxe.io.Path;
import openfl.utils.ByteArray;
import lime.media.AudioBuffer;
import sys.FileSystem;
import flash.media.Sound;

#end
import lime.ui.FileDialog;
import lime.app.Event;
import haxe.Json;
import tjson.TJSON;
import yaml.Yaml;
import yaml.util.ObjectMap;
import openfl.net.FileReference;
import openfl.utils.ByteArray;
using StringTools;

class NewCharacterState extends MusicBeatState
{
var addCharUi:FlxUI;
var nameText:FlxUIInputText;
var mainPngButton:FlxButton;
var mainXmlButton:FlxButton;
var deadPngButton:FlxButton;
var deadXmlButton:FlxButton;
var crazyPngButton:FlxButton;
var crazyXmlButton:FlxButton;
var likeText:FlxUIInputText;
var iconAlive:FlxUINumericStepper;
var iconDead:FlxUINumericStepper;
var iconPoison:FlxUINumericStepper;
var finishButton:FlxButton;
var coolFile:FileReference;
var coolData:ByteArray;
var epicFiles:Dynamic;
private var grpSongs:FlxTypedGroup<Alphabet>;
private var curPlaying:Bool = false;

override function create()
{
addCharUi = new FlxUI();
FlxG.mouse.visible = true;
epicFiles = {
"charpng": null,
"charxml":null,
"deadpng":null,
"deadxml":null,
"crazyxml":null,
"crazypng":null
};
var bg:FlxSprite = new FlxSprite().loadGraphic('assets/images/menuBGBlue.png');
add(bg);
mainPngButton = new FlxButton(10,10,"char.png",function ():Void {
var coolDialog = new FileDialog();
coolDialog.browse();
coolDialog.onSelect.add(function (path:String):Void {
epicFiles.charpng = path;
});
});
likeText = new FlxUIInputText(100, 10, 70,"bf");
nameText = new FlxUIInputText(100,50,70,"template");
var aliveText = new FlxText(100,70,"Alive Icon");
iconAlive = new FlxUINumericStepper(100, 90,1,0,0,49);
var deadText = new FlxText(100,120,"Dead Icon");
iconDead = new FlxUINumericStepper(100, 140,1,1,0,49);
var poisonText = new FlxText(100,170,"Poison Icon");
iconPoison = new FlxUINumericStepper(100, 190,1,24,0,49);
add(nameText);
add(likeText);
add(iconAlive);
add(iconDead);
add(iconPoison);
add(poisonText);
add(deadText);
add(aliveText);
add(mainPngButton);
mainXmlButton = new FlxButton(10,60,"char.xml/txt",function ():Void {
var coolDialog = new FileDialog();
coolDialog.browse();
coolDialog.onSelect.add(function (path:String):Void {
epicFiles.charxml = path;
});
});
add(mainXmlButton);
deadPngButton = new FlxButton(10,110,"dead.png",function ():Void {
var coolDialog = new FileDialog();
coolDialog.browse();
coolDialog.onSelect.add(function (path:String):Void {
epicFiles.deadpng = path;
});
});
crazyPngButton = new FlxButton(10,170,"crazy.png",function ():Void {
var coolDialog = new FileDialog();
coolDialog.browse();
coolDialog.onSelect.add(function (path:String):Void {
epicFiles.crazypng = path;
});
});
deadXmlButton = new FlxButton(10,220,"dead.xml",function ():Void {
var coolDialog = new FileDialog();
coolDialog.browse();
coolDialog.onSelect.add(function (path:String):Void {
epicFiles.deadxml = path;
});
});
crazyXmlButton = new FlxButton(10,260,"crazy.xml",function ():Void {
var coolDialog = new FileDialog();
coolDialog.browse();
coolDialog.onSelect.add(function (path:String):Void {
epicFiles.crazyxml = path;
});
});
finishButton = new FlxButton(FlxG.width - 170, FlxG.height - 50, "Finish", function():Void {
writeCharacters();
FlxG.switchState(new SaveDataState());
});
add(crazyXmlButton);
add(deadXmlButton);
add(deadPngButton);
add(finishButton);
add(crazyPngButton);
super.create();
}

override function update(elapsed:Float)
{
super.update(elapsed);

}
function writeCharacters() {
// check to see if directory exists
#if sys
if (!FileSystem.exists('assets/images/custom_chars/'+nameText.text)) {
FileSystem.createDirectory('assets/images/custom_chars/'+nameText.text);
}
trace(epicFiles.charpng);
trace("hello");
File.copy(epicFiles.charpng,'assets/images/custom_chars/'+nameText.text+'/char.png');
// if it was an xml file save it as one
// otherwise save it as txt
if (StringTools.endsWith(epicFiles.charxml,"xml"))
File.copy(epicFiles.charxml,'assets/images/custom_chars/'+nameText.text+'/char.xml');
else
File.copy(epicFiles.charxml,'assets/images/custom_chars/'+nameText.text+'/char.txt');
if (epicFiles.deadpng != null) {
File.copy(epicFiles.deadpng,'assets/images/custom_chars/'+nameText.text+'/dead.png');
File.copy(epicFiles.deadxml,'assets/images/custom_chars/'+nameText.text+'/dead.xml');
}
if (epicFiles.crazypng != null) {
File.copy(epicFiles.crazypng,'assets/images/custom_chars/'+nameText.text+'/crazy.png');
File.copy(epicFiles.crazyxml,'assets/images/custom_chars/'+nameText.text+'/crazy.xml');
}
trace("hello");
var epicCharFile:Dynamic =CoolUtil.parseJson(Assets.getText('assets/images/custom_chars/custom_chars.jsonc'));
trace("parsed");
var coolReplacementMap:ObjectMap<String, Dynamic> = new ObjectMap<String, Dynamic>();
Reflect.setField(epicCharFile,nameText.text,{like:likeText.text,icons: [Std.int(iconAlive.value),Std.int(iconDead.value),Std.int(iconPoison.value)]});

File.saveContent('assets/images/custom_chars/custom_chars.jsonc', CoolUtil.stringifyJson(epicCharFile));
trace("cool stuff");
#end
}
}
Loading

0 comments on commit 8f4f4f8

Please sign in to comment.