Skip to content

Commit 7d0f882

Browse files
committed
idk if it compiles buti it should lol
1 parent b64cca8 commit 7d0f882

File tree

6 files changed

+126
-6
lines changed

6 files changed

+126
-6
lines changed

source/archipelago/APGameState.hx

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1098,6 +1098,16 @@ class APGameState
10981098
trace("Loaded " + [for (key in unlockedSanityItems.keys()) key].length + " unlocked sanity items from save");
10991099
}
11001100

1101+
// Load shop
1102+
if (_saveData.hasItem("apShopItems"))
1103+
{
1104+
var apShopItems:Array<MiniItem> = _saveData.getItem("apShopItems");
1105+
for (item in apShopItems)
1106+
ShopData.items.set(item.name, Item.makeItemFromMini(item));
1107+
1108+
trace("Loaded " + [for (key in unlockedSanityItems.keys()) key].length + " unlocked sanity items from save");
1109+
}
1110+
11011111
_saveData.save();
11021112
}
11031113

@@ -1136,6 +1146,13 @@ class APGameState
11361146
// Save sanity data
11371147
_saveData.addItem("unlockedSanityItems", [for (name => data in unlockedSanityItems) {name: name, data: data}]);
11381148

1149+
// put everything in the array to grab later
1150+
var shopItems:Array<MiniItem> = [];
1151+
for (item in ShopData.items.keys())
1152+
shopItems.push(Item.makeMiniItemFromItem(ShopData.items.get(item)));
1153+
1154+
_saveData.addItem("apShopItems", shopItems);
1155+
11391156
_saveData.save();
11401157
trace("Save data updated!");
11411158
}

source/import.hx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ import objects.AudioDisplay;
8080
import objects.BGSprite;
8181
import objects.FlxAtlasSprite;
8282
import shaders.*;
83+
import shop.*;
8384
import stages.BaseStage;
8485
import states.LoadingState;
8586
import states.PlayState;

source/objects/Note.hx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -731,9 +731,7 @@ class Note extends NoteObject
731731
if (this is archipelago.APNote)
732732
{
733733
trace("AP Color.");
734-
rgbShader.r = 0xFF313131;
735-
rgbShader.g = 0xFFFFFFFF;
736-
rgbShader.b = 0xFFB4B4B4;
734+
shader = null;
737735
}
738736
}
739737
else

source/shop/DaShop.hx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,10 +103,12 @@ class DaShop extends MusicBeatState
103103
image.ID = max;
104104
icons.add(image);
105105
max++;
106+
106107
var text:FlxText = new FlxText(image.x + 50, image.y + 150, 0, ShopData.items.get(i)[1], 15);
107108
text.setFormat(Paths.font("comboFont.ttf"), 25, FlxColor.WHITE, LEFT, FlxTextBorderStyle.OUTLINE, FlxColor.BLACK);
108109
text.ID = max-1;
109110
icons.add(text);
111+
110112
itemArray.push([i, ShopData.items.get(i)[0], ShopData.items.get(i)[1], ShopData.items.get(i)[2], ShopData.items.get(i)[3], ShopData.items.get(i)[4]]);
111113
}
112114
}
@@ -190,8 +192,6 @@ class DaShop extends MusicBeatState
190192
if (curItem >= max)
191193
curItem = 0;
192194

193-
194-
195195
if (itemArray[curItem] != null)
196196
{
197197
itemName = itemArray[curItem][0];

source/shop/Item.hx

Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
package shop;
2+
3+
typedef MiniItem {
4+
var icon:FlxSprite;
5+
var desc:String;
6+
var price:Int;
7+
var isHidden:Bool;
8+
var isBought:Bool;
9+
var inShop:Bool;
10+
var amountOwned:Int;
11+
var extraData:Map<String, Dynamic>;
12+
var globalEXData:Map<String, Dynamic>;
13+
var category:String;
14+
var priceTxt:FlxText;
15+
var amountAllowedToBuy:Int;
16+
var apItemID:Int;
17+
var apItemName:String;
18+
var apLocID:Int;
19+
var apLocName:String;
20+
}
21+
22+
class Item extends FlxObject {
23+
//Per-Item Variables
24+
public var icon:FlxSprite;
25+
public var desc:String;
26+
public var price:Int;
27+
public var isHidden:Bool = false;
28+
public var isBought:Bool = false;
29+
public var inShop(default, set):Bool = false;
30+
public var amountOwned:Int = 0;
31+
public var extraData:Map<String, Dynamic> = [];
32+
33+
private function set_inShop(value:Bool):Bool {
34+
if (!value && priceTxt != null) {
35+
remove(priceTxt);
36+
priceTxt.destroy();
37+
} else {
38+
priceTxt = new FlxText(x + 50, y + 150, 0, price, 15);
39+
priceTxt.setFormat(Paths.font("comboFont.ttf"), 25, FlxColor.WHITE, LEFT, FlxTextBorderStyle.OUTLINE, FlxColor.BLACK);
40+
add(priceTxt);
41+
}
42+
return value;
43+
}
44+
45+
//Global Variables
46+
public static var globalEXData:Map<String, Dynamic> = [];
47+
48+
//Shop-Specific Variables
49+
public var category:String = 'base';
50+
public var priceTxt:FlxText;
51+
public var amountAllowedToBuy:Int = 1;
52+
53+
//AP-Specific Variables
54+
public var apItemID:Int;
55+
public var apItemName:String;
56+
public var apLocID:Int;
57+
public var apLocName:String;
58+
59+
public function new(name:String, desc:String, price:Int, image:String, ?isHidden:Bool) {
60+
super();
61+
62+
icon = new FlxSprite().loadGraphic(Paths.image('shop/'+image));
63+
this.desc = desc;
64+
this.price = price;
65+
this.isHidden = isHidden;
66+
}
67+
68+
public static function makeItemFromMini(miniItem:MiniItem):Item {
69+
var newItem = new Item(miniItem.name, miniItem.desc, miniItem.price, miniItem.image, miniItem.isHidden);
70+
newItem.isBought = miniItem.isBought;
71+
newItem.amountOwned = miniItem.amountOwned;
72+
newItem.extraData = miniItem.extraData;
73+
newItem.category = miniItem.category;
74+
newItem.priceTxt = miniItem.priceTxt;
75+
newItem.amountAllowedToBuy = miniItem.amountAllowedToBuy;
76+
newItem.apItemID = miniItem.apItemID;
77+
newItem.apItemName = miniItem.apItemName;
78+
newItem.apLocID = miniItem.apLocID;
79+
newItem.apLocName = miniItem.apLocName;
80+
return newItem;
81+
}
82+
83+
public static function makeMiniItemFromItem(item:Item):MiniItem {
84+
var newMiniItem = new MiniItem();
85+
newMiniItem.name = item.name;
86+
newMiniItem.desc = item.desc;
87+
newMiniItem.price = item.price;
88+
newMiniItem.image = item.image;
89+
newMiniItem.isHidden = item.isHidden;
90+
newMiniItem.isBought = miniItem.isBought;
91+
newMiniItem.amountOwned = miniItem.amountOwned;
92+
newMiniItem.extraData = miniItem.extraData;
93+
newMiniItem.category = miniItem.category;
94+
newMiniItem.priceTxt = miniItem.priceTxt;
95+
newMiniItem.amountAllowedToBuy = miniItem.amountAllowedToBuy;
96+
newMiniItem.apItemID = miniItem.apItemID;
97+
newMiniItem.apItemName = miniItem.apItemName;
98+
newMiniItem.apLocID = miniItem.apLocID;
99+
newMiniItem.apLocName = miniItem.apLocName;
100+
return newMiniItem;
101+
}
102+
}

source/shop/ShopData.hx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
package shop;
22

3+
import shop.*;
4+
35
class MoneyPopup extends FlxSpriteGroup {
46
public var onFinish:Void->Void = null;
57
var alphaTween:FlxTween;
@@ -91,7 +93,7 @@ class MoneyPopup extends FlxSpriteGroup {
9193
}
9294

9395
class ShopData {
94-
public static var items:Map<String, Dynamic> = new Map<String, Dynamic>();
96+
public static var items:Map<String, Item> = new Map<String, Item>();
9597
public static function initShop()
9698
{
9799
//items.set('Item Name', ['Description', Cost (Int), 'Image Name', Is Hidden (Bool), Is Bought (Bool)]);

0 commit comments

Comments
 (0)