Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
RishiRecon
GitHub Repository: RishiRecon/exploits
Path: blob/main/misc/retro-bowl/html5game/uph_poki.js
28391 views
1
console.log("Poki wrapper load");
2
///~
3
function poki_init_raw() {
4
console.log("Poki wrapper init");
5
// fix GMS1 bug with iframes
6
var ctr = document.getElementById("gm4html5_div_id");
7
if (ctr && !ctr.frames) ctr.frames = [];
8
return 0;
9
}
10
///~
11
function poki_script_closure_raw(self, other, script, custom) {
12
return function (result) {
13
window.gml_Script_gmcallback_poki_closure(self, other, script, result, custom);
14
};
15
}
16
17
function poki_is_blocked() {
18
return !window.PokiSDK_OK;
19
}
20
21
function poki_gameplay_start() {
22
if (PokiSDK) PokiSDK.gameplayStart();
23
}
24
25
function poki_gameplay_stop() {
26
if (PokiSDK) PokiSDK.gameplayStop();
27
}
28
29
function poki_happy_time(magnitude) {
30
if (PokiSDK) PokiSDK.happyTime(magnitude);
31
}
32
33
///~
34
function poki_commercial_break_raw(fn) {
35
if (PokiSDK) {
36
PokiSDK.commercialBreak().then(function () {
37
fn(true);
38
});
39
} else
40
setTimeout(function () {
41
fn(false);
42
}, 0);
43
}
44
45
///~
46
function poki_rewarded_break_raw(fn) {
47
if (PokiSDK) {
48
PokiSDK.rewardedBreak().then(fn);
49
} else
50
setTimeout(function () {
51
fn(false);
52
}, 0);
53
}
54
55
/// https://yal.cc/gamemaker-html5-loading-bar-extended/
56
var inst = {};
57
///~
58
function poki_loadbar(ctx, width, height, total, current, image) {
59
if (window.PokiSDK) {
60
// if you have your own loadbar, just copy this block in there
61
if (window.PokiSDK_loadState == 0) {
62
window.PokiSDK_isLoading = 1;
63
PokiSDK.gameLoadingStart();
64
}
65
PokiSDK.gameLoadingProgress({ percentageDone: current / total });
66
if (current >= total && window.PokiSDK_loadState != 2) {
67
window.PokiSDK_loadState = 2;
68
PokiSDK.gameLoadingFinished();
69
}
70
}
71
72
function getv(s) {
73
if (window.gml_Script_gmcallback_poki_loadbar) {
74
return window.gml_Script_gmcallback_poki_loadbar(inst, null, s, current, total, width, height, image ? image.width : 0, image ? image.height : 0);
75
} else return undefined;
76
}
77
function getf(s, d) {
78
var r = getv(s);
79
return typeof r == "number" ? r : d;
80
}
81
function getw(s, d) {
82
var r = getv(s);
83
return r && r.constructor == Array ? r : d;
84
}
85
function getc(s, d) {
86
var r = getv(s);
87
if (typeof r == "number") {
88
r = r.toString(16);
89
while (r.length < 6) r = "0" + r;
90
return "#" + r;
91
} else if (typeof r == "string") {
92
return r;
93
} else return d;
94
}
95
// get parameters:
96
var backgroundColor = getc("background_color", "#FFFFFF");
97
var barBackgroundColor = getc("bar_background_color", "#FFFFFF");
98
var barForegroundColor = getc("bar_foreground_color", "#242238");
99
var barBorderColor = getc("bar_border_color", "#242238");
100
var barWidth = getf("bar_width", Math.round(width * 0.6));
101
var barHeight = getf("bar_height", 20);
102
var barBorderWidth = getf("bar_border_width", 2);
103
var barOffset = getf("bar_offset", 10);
104
// background:
105
ctx.fillStyle = backgroundColor;
106
ctx.fillRect(0, 0, width, height);
107
// image:
108
var totalHeight, barTop;
109
if (image != null) {
110
var rect = getw("image_rect");
111
if (!rect) rect = [0, 0, image.width, image.height];
112
totalHeight = rect[3] + barOffset + barHeight;
113
var image_y = (height - totalHeight) >> 1;
114
ctx.drawImage(image, rect[0], rect[1], rect[2], rect[3], (width - rect[2]) >> 1, image_y, rect[2], rect[3]);
115
barTop = image_y + rect[3] + barOffset;
116
} else barTop = (height - barHeight) >> 1;
117
// bar border:
118
var barLeft = (width - barWidth) >> 1;
119
ctx.fillStyle = barBorderColor;
120
ctx.fillRect(barLeft, barTop, barWidth, barHeight);
121
//
122
var barInnerLeft = barLeft + barBorderWidth;
123
var barInnerTop = barTop + barBorderWidth;
124
var barInnerWidth = barWidth - barBorderWidth * 2;
125
var barInnerHeight = barHeight - barBorderWidth * 2;
126
// bar background:
127
ctx.fillStyle = barBackgroundColor;
128
ctx.fillRect(barInnerLeft, barInnerTop, barInnerWidth, barInnerHeight);
129
// bar foreground:
130
var barLoadedWidth = Math.round((barInnerWidth * current) / total);
131
ctx.fillStyle = barForegroundColor;
132
ctx.fillRect(barInnerLeft, barInnerTop, barLoadedWidth, barInnerHeight);
133
}
134
///~
135
function poki_get_team_raw() {
136
return PokiSDK.getURLParam("team");
137
}
138
139
function poki_set_team_raw(team) {
140
return window.parent.postMessage({ type: "RetroBowl_teamSwitch", content: { team } }, "*");
141
}
142