Skip to content

Commit 1e4f36a

Browse files
committed
Spectator Mode (Beta) and massive Code Cleanup/Refactor
1 parent 0c4d3ce commit 1e4f36a

37 files changed

Lines changed: 3106 additions & 1770 deletions

only-up-64-plugin/a-bytereader.lua

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
--- @class ByteReader
22

3-
local string_sub,string_unpack = string.sub,string.unpack
3+
-- Localize for performance.
4+
local string_sub,string_unpack =
5+
string.sub,string.unpack
46

57
local ByteReader = {}
68
ByteReader.__index = ByteReader
@@ -14,7 +16,7 @@ function ByteReader:new(bytestring)
1416
return setmetatable(self, ByteReader)
1517
end
1618

17-
--- Class Functions ---
19+
-- Class Functions
1820
local function deserialize(self, fmt)
1921
local v; v, self.offset = string_unpack(fmt, self.data, self.offset)
2022
return v
@@ -24,7 +26,7 @@ function ByteReader:at_end()
2426
return self.offset >= #self.data
2527
end
2628

27-
--- Data Functions ---
29+
-- Data Functions
2830
function ByteReader:bool() return self:u8() ~= 0 end ---@return boolean
2931
function ByteReader:u8() return deserialize(self, "<B") end ---@return integer
3032
function ByteReader:s8() return deserialize(self, "<b") end ---@return integer
@@ -57,4 +59,4 @@ function ByteReader:string()
5759
return str
5860
end
5961

60-
return ByteReader
62+
return ByteReader

only-up-64-plugin/a-bytewriter.lua

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
--- @class ByteWriter
22

3-
local string_pack,string_sub,string_unpack,table_insert = string.pack,string.sub,string.unpack,table.insert
3+
-- Localize for performance.
4+
local string_pack,string_sub,string_unpack,table_insert =
5+
string.pack,string.sub,string.unpack,table.insert
46

57
local ByteWriter = {}
68
ByteWriter.__index = ByteWriter
@@ -15,7 +17,7 @@ function ByteWriter:new()
1517
return self
1618
end
1719

18-
--- Class Functions ---
20+
-- Class Functions
1921
function ByteWriter:clear()
2022
if not self.buffer then return end
2123
for i = #self.buffer, 1, -1 do
@@ -34,7 +36,7 @@ function ByteWriter:is_empty()
3436
return #self.buffer == 0
3537
end
3638

37-
--- Data Functions ---
39+
-- Data Functions
3840
function ByteWriter:bool(value)
3941
table_insert(self.buffer, string_pack("<B", ((value and 1) or 0)))
4042
end

only-up-64-plugin/a-checkpoints.lua

Lines changed: 0 additions & 39 deletions
This file was deleted.

only-up-64-plugin/a-globals.lua

Lines changed: 349 additions & 129 deletions
Large diffs are not rendered by default.

only-up-64-plugin/a-input.lua

Lines changed: 0 additions & 19 deletions
This file was deleted.

only-up-64-plugin/a-movement.lua

Lines changed: 0 additions & 110 deletions
This file was deleted.

only-up-64-plugin/a-promos.lua

Lines changed: 0 additions & 49 deletions
This file was deleted.
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
-- Sets the HUD color multiplied dependent on the pause status.
2+
--- @param r integer - red
3+
--- @param g integer - green
4+
--- @param b integer - blue
5+
--- @param a integer - alpha
6+
function djui_hud_set_adjusted_color(r, g, b, a)
7+
local multiplier = is_game_paused() and 0.5 or 1
8+
djui_hud_set_color(
9+
r * multiplier,
10+
g * multiplier,
11+
b * multiplier,
12+
a
13+
)
14+
end
15+
16+
-- Renders recolored player heads - modified from EmilyEmmi's Shine Thief
17+
-- https://discord.com/channels/752682015614173235/755907254318006362/1146275236325625897
18+
--- @param index integer
19+
--- @param x integer
20+
--- @param y integer
21+
--- @param scale_x number
22+
--- @param scale_y number
23+
function render_player_head(index, x, y, scale_x, scale_y)
24+
local head_hud = get_texture_info("hud_head_recolor")
25+
26+
local parts = {
27+
SKIN,
28+
HAIR,
29+
CAP,
30+
}
31+
local m = gMarioStates[index]
32+
local np = gNetworkPlayers[index]
33+
34+
local alpha = (m.health <= 0xff or is_game_paused()) and 100 or 255
35+
local tile_y = m.character.type
36+
for i = 1, #parts do
37+
local part = parts[i]
38+
if tile_y == 2 and
39+
part == HAIR then
40+
part = GLOVES
41+
end
42+
local color = network_player_get_override_palette_color(np, part)
43+
44+
djui_hud_set_color(color.r, color.g, color.b, alpha)
45+
djui_hud_render_texture_tile(head_hud, x, y, scale_x, scale_y, (i - 1) * 16, tile_y * 16, 16, 16)
46+
end
47+
48+
djui_hud_set_color(255, 255, 255, alpha)
49+
djui_hud_render_texture_tile(head_hud, x, y, scale_x, scale_y, #parts * 16, tile_y * 16, 16, 16)
50+
djui_hud_render_texture_tile(head_hud, x, y, scale_x, scale_y, (#parts + 1) * 16, tile_y * 16, 16, 16)
51+
end
52+
53+
-- Renders recolored player heads from provided model/hair/skin/cap - modified from EmilyEmmi's Shine Thief
54+
-- https://discord.com/channels/752682015614173235/755907254318006362/1146275236325625897
55+
--- @param model integer
56+
--- @param hair integer
57+
--- @param skin integer
58+
--- @param cap integer
59+
--- @param x integer
60+
--- @param y integer
61+
--- @param scale_x number
62+
--- @param scale_y number
63+
function render_player_head_from_parts(model, hair, skin, cap, x, y, scale_x, scale_y)
64+
local head_hud = get_texture_info("hud_head_recolor")
65+
local alpha = (m.health <= 0xff or is_game_paused()) and 100 or 255
66+
local tile_y = model
67+
68+
local skin_color = unpack_color_int(skin)
69+
djui_hud_set_color(skin_color.r, skin_color.g, skin_color.b, alpha)
70+
djui_hud_render_texture_tile(head_hud, x, y, scale_x, scale_y, (1 - 1) * 16, tile_y * 16, 16, 16)
71+
local hair_color = unpack_color_int(hair)
72+
djui_hud_set_color(hair_color.r, hair_color.g, hair_color.b, alpha)
73+
djui_hud_render_texture_tile(head_hud, x, y, scale_x, scale_y, (2 - 1) * 16, tile_y * 16, 16, 16)
74+
local cap_color = unpack_color_int(cap)
75+
djui_hud_set_color(cap_color.r, cap_color.g, cap_color.b, alpha)
76+
djui_hud_render_texture_tile(head_hud, x, y, scale_x, scale_y, (3 - 1) * 16, tile_y * 16, 16, 16)
77+
78+
djui_hud_set_color(255, 255, 255, alpha)
79+
djui_hud_render_texture_tile(head_hud, x, y, scale_x, scale_y, 3 * 16, tile_y * 16, 16, 16)
80+
djui_hud_render_texture_tile(head_hud, x, y, scale_x, scale_y, 4 * 16, tile_y * 16, 16, 16)
81+
end

0 commit comments

Comments
 (0)