-
Notifications
You must be signed in to change notification settings - Fork 1
/
freeCircuits.js
126 lines (104 loc) · 2.89 KB
/
freeCircuits.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
/*
* Code by EpicYoshiMaster
*
* Handles functionality of Free Circuits
*/
ig.module('yoshi-open-circuits-free')
.defines(() => {
//I didn't really want to resort to global level variables
//but the circuit menu seems to be really annoying to access from outside
let useFreeCircuits = false;
sc.CircuitMenu.inject({
hotkeyFree: null,
init(...args) {
this.hotkeyFree = new sc.ButtonGui("\\i[help3]" + ig.lang.get("sc.gui.menu.hotkeys.free-circuits"), void 0, true, sc.BUTTON_TYPE.SMALL);
this.hotkeyFree.startHidden = true;
this.hotkeyFree.doStateTransition("HIDDEN");
this.hotkeyFree.setActive(false);
this.hotkeyFree.keepMouseFocus = true;
this.hotkeyFree.hook.transitions = {
DEFAULT: {
state: {},
time: 0.2,
timeFunction: KEY_SPLINES.EASE
},
HIDDEN: {
state: {
offsetY: -this.hotkeyFree.hook.size.y
},
time: 0.2,
timeFunction: KEY_SPLINES.LINEAR
}
};
this.hotkeyFree.onButtonPress = this._onFreeButtonPressed.bind(this);
useFreeCircuits = false;
this.parent(...args);
},
_onFreeButtonPressed: function() {
if(!useFreeCircuits) {
useFreeCircuits = true;
this.hotkeyFree.setText("\\i[help3]" + ig.lang.get("sc.gui.menu.hotkeys.paid-circuits"));
}
else {
useFreeCircuits = false;
this.hotkeyFree.setText("\\i[help3]" + ig.lang.get("sc.gui.menu.hotkeys.free-circuits"));
}
},
exitMenu() {
sc.menu.buttonInteract.removeGlobalButton(this.hotkeyFree);
this.parent();
},
_onhotkeyFreeCheck: function() {
return sc.control.menuHotkeyHelp3();
},
_addHotKeys(b) {
sc.menu.buttonInteract.addGlobalButton(this.hotkeyFree, this._onhotkeyFreeCheck.bind(this));
this.parent(b);
},
commitHotKeysToTopBar(b) {
sc.menu.addHotkey(function() {
return this.hotkeyFree
}.bind(this));
this.parent(b);
},
modelChanged: function(b, a) {
this.parent(b, a);
if(b == sc.menu && a == sc.MENU_EVENT.SKILL_TREE_SELECT) {
if(sc.menu.currentSkillTree < 0) {
this.hotkeyFree.startHidden = true;
this.hotkeyFree.doStateTransition("HIDDEN");
this.hotkeyFree.setActive(false);
}
else {
this.hotkeyFree.startHidden = false;
this.hotkeyFree.setActive(true);
this.hotkeyFree.doStateTransition("DEFAULT");
}
}
}
});
//Free up getting past blocked nodes
sc.CircuitTreeDetail.Node.inject({
_checkParentForBlock(a) {
if(useFreeCircuits) {
return false;
}
else {
return this.parent(a);
}
}
});
//Wanted a way to make sure this isn't a hard override
//This stores the old one to make sure it still goes through correctly
sc.OldSkillTools = sc.SkillTools;
sc.SkillTools = {
getCPCost: function(a, b) {
if(useFreeCircuits) {
return 0;
}
else {
return sc.OldSkillTools.getCPCost(a, b);
}
}
}
});