-
Notifications
You must be signed in to change notification settings - Fork 1
/
renderer.js
129 lines (109 loc) · 5.59 KB
/
renderer.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
127
128
const electron = require('electron');
const {ipcRenderer} = electron;
ipcRenderer.on('romName', (event, accessToken) => {
document.getElementById("romFileName").innerText = accessToken;
});
ipcRenderer.on('backgroundImage', (event, accessToken) => {
document.getElementById("displayBackgroundImage").src = "./data/background/images/" + accessToken + ".png";
});
ipcRenderer.on('postAttackImage', (event, accessToken, obj) => {
if(accessToken == "Heavy Shake Foe" || accessToken == "Tickle Shake Foe" || accessToken == "Hit Foe In Circle"
|| accessToken == "Slice-X" || accessToken == "Come Back" || accessToken == "Startle Foe" || accessToken == "Push Away"
|| accessToken == "Push Away 2"
){
document.getElementById("displayPostAttackImage").src = "./data/post-attack/" + accessToken + ".gif";
} else{
document.getElementById("displayPostAttackImage").src = "./data/post-attack/" + accessToken + ".png";
}
document.getElementById("description").innerHTML = obj.description;
});
ipcRenderer.on('preAttackImage', (event, accessToken, obj) => {
if(accessToken == "Move Circle User" || accessToken == "Move Down User" || accessToken == "Move Left and Right User" || accessToken == "Shake Up & Down User"
|| accessToken == "Shake Turn Red" || accessToken == "Slight Shake User" || accessToken == "User Yawns"
|| accessToken == "Air Cutter Start" || accessToken == "Ancientpower Lift Rocks" || accessToken == "Charm"
|| accessToken == "Destiny Bond Surface" || accessToken == "Leafs" || accessToken == "Shooting Stars" || accessToken == "Buff Up"
|| accessToken == "Ready Aim" || accessToken == "Fade But Not You" || accessToken == "Invert Background" || accessToken == "Sun Rays"
|| accessToken == "Shine" || accessToken == "Three Charges"
){
document.getElementById("displayPreAttackImage").src = "./data/pre-attack/" + accessToken + ".gif";
} else {
document.getElementById("displayPreAttackImage").src = "./data/pre-attack/" + accessToken + ".png";
}
document.getElementById("description").innerHTML = obj.description
});
//Rom not loaded. Display error popup
ipcRenderer.on('romNotLoaded', (event) => {
alert("Error: ROM not loaded")
});
//Generic Popup Error Message
ipcRenderer.on('errorMessage', (event, message) => {
alert(message)
});
//Handles which radio buttons to enable/disable depending on background. Some backgrounds don't allow certain scrolling types
ipcRenderer.on('scrollRadioButton', (event, vertical, horizontal) => {
//If background has no vertical or background scroll, disable scroll speed
if(vertical != true && horizontal != true){
document.getElementById("select-scrollSpeed").disabled = true;
} else {
document.getElementById("select-scrollSpeed").disabled = false;
}
//If background has no vertical scroll option, disable vertical scroll button and reset to None Selected
if(vertical != true){
document.getElementById("verticalScroll").disabled = true;
document.getElementById("verticalScroll").checked = false;
document.getElementById("noScroll").checked = true;
} else{
document.getElementById("verticalScroll").disabled = false;
}
//If background has no horizontal scroll option, disable vertical scroll button and reset to None Selected
if(horizontal != true){
document.getElementById("horizontalScroll").disabled = true;
document.getElementById("horizontalScroll").checked = false;
document.getElementById("noScroll").checked = true;
} else{
document.getElementById("horizontalScroll").disabled = false;
}
});
//Handles disabling/enabling Keep Background Checkboxes
ipcRenderer.on('keepBackgroundCheckbox', (event, backgroundName) => {
//Disable checkboxes if default is selected so that the user isn't confused
if(backgroundName == "Default"){
document.getElementById("checkbox1").checked = false;
document.getElementById("checkbox2").checked = false;
document.getElementById("checkbox3").checked = false;
document.getElementById("checkbox4").checked = false;
document.getElementById("checkbox1").disabled = true;
document.getElementById("checkbox2").disabled = true;
document.getElementById("checkbox3").disabled = true;
document.getElementById("checkbox4").disabled = true;
} else{
document.getElementById("checkbox1").disabled = false;
document.getElementById("checkbox2").disabled = false;
document.getElementById("checkbox3").disabled = false;
document.getElementById("checkbox4").disabled = false;
}
});
/////////////Insert Animation///////////////////
ipcRenderer.on('setInsertWindowVariables', (event, bytes, hex) => {
document.getElementById("bytesNeeded").innerText = bytes;
document.getElementById("hex").value = hex;
});
ipcRenderer.on('setInputMemoryOffset', (event, memoryOffset) => {
document.getElementById("offset").value = memoryOffset;
});
///////////////Search Free Space/////////////////////
ipcRenderer.on('setFreeSpaceWindowInitialParameters', (event, bytesNeeded) => {
document.getElementById("bytesNeeded").value = bytesNeeded;
});
ipcRenderer.on('setSearchLoadingSpinner', (event, value) => {
console.log('dog')
if(value == true){
document.getElementById("searchLoadingSpinner").className = "spinner-border spinner-border-sm";
}
else {
document.getElementById("searchLoadingSpinner").className = "";
}
});
ipcRenderer.on('setInsertMemoryOffset', (event, offset) => {
document.getElementById("memoryOffset").value = offset;
});