|
1 | | ---- STEAMODDED CORE |
2 | | ---- MODULE CORE |
3 | | - |
4 | | -SMODS = {} |
5 | | -MODDED_VERSION = require'SMODS.version' |
6 | | -RELEASE_VERSION = require'SMODS.release' |
7 | | -SMODS.id = 'Steamodded' |
8 | | -SMODS.version = MODDED_VERSION:gsub('%-STEAMODDED', '') |
9 | | -SMODS.can_load = true |
10 | | -SMODS.meta_mod = true |
11 | | -SMODS.config_file = 'config.lua' |
12 | | - |
13 | | --- Include lovely and nativefs modules |
14 | | -local nativefs = require "nativefs" |
15 | | -local lovely = require "lovely" |
16 | | -local json = require "json" |
17 | | - |
18 | | -local lovely_mod_dir = lovely.mod_dir:gsub("/$", "") |
19 | | -NFS = nativefs |
20 | | --- make lovely_mod_dir an absolute path. |
21 | | --- respects symlink/.. combos |
22 | | -NFS.setWorkingDirectory(lovely_mod_dir) |
23 | | -lovely_mod_dir = NFS.getWorkingDirectory() |
24 | | --- make sure NFS behaves the same as love.filesystem |
25 | | -NFS.setWorkingDirectory(love.filesystem.getSaveDirectory()) |
26 | | - |
27 | | -JSON = json |
28 | | - |
29 | | -local function set_mods_dir() |
30 | | - local love_dirs = { |
31 | | - love.filesystem.getSaveDirectory(), |
32 | | - love.filesystem.getSourceBaseDirectory() |
33 | | - } |
34 | | - for _, love_dir in ipairs(love_dirs) do |
35 | | - if lovely_mod_dir:sub(1, #love_dir) == love_dir then |
36 | | - -- relative path from love_dir |
37 | | - SMODS.MODS_DIR = lovely_mod_dir:sub(#love_dir+2) |
38 | | - NFS.setWorkingDirectory(love_dir) |
39 | | - return |
40 | | - end |
41 | | - end |
42 | | - SMODS.MODS_DIR = lovely_mod_dir |
43 | | -end |
44 | | -set_mods_dir() |
45 | | - |
46 | | -local function find_self(directory, target_filename, target_line, depth) |
47 | | - depth = depth or 1 |
48 | | - if depth > 3 then return end |
49 | | - for _, filename in ipairs(NFS.getDirectoryItems(directory)) do |
50 | | - local file_path = directory .. "/" .. filename |
51 | | - local file_type = NFS.getInfo(file_path).type |
52 | | - if file_type == 'directory' or file_type == 'symlink' then |
53 | | - if not NFS.getInfo(file_path.."/.lovelyignore") then |
54 | | - local f = find_self(file_path, target_filename, target_line, depth+1) |
55 | | - if f then return f end |
56 | | - end |
57 | | - elseif filename == target_filename then |
58 | | - local first_line = NFS.read(file_path):match('^(.-)\n') |
59 | | - if first_line == target_line then |
60 | | - -- use parent directory |
61 | | - return directory:match('^(.+/)') |
62 | | - end |
63 | | - end |
64 | | - end |
65 | | -end |
66 | | - |
67 | | -SMODS.path = find_self(SMODS.MODS_DIR, 'core.lua', '--- STEAMODDED CORE') |
68 | | - |
| 1 | +assert(SMODS.path, "SMODS was not properly setup.\n\n!!!!!!!!!!!!!!\nPlease make sure your lovely is up to date (Minimum lovely v0.9.0)\n!!!!!!!!!!!!!!") |
69 | 2 | for _, path in ipairs { |
70 | 3 | "src/ui.lua", |
71 | 4 | "src/index.lua", |
72 | 5 | "src/utils.lua", |
73 | 6 | "src/overrides.lua", |
74 | 7 | "src/game_object.lua", |
75 | | - "src/logging.lua", |
76 | 8 | "src/compat_0_9_8.lua", |
77 | | - "src/loader.lua", |
78 | 9 | } do |
79 | | - assert(load(NFS.read(SMODS.path..path), ('=[SMODS _ "%s"]'):format(path)))() |
| 10 | + assert(load(SMODS.NFS.read(SMODS.path..path), ('=[SMODS _ "%s"]'):format(path)))() |
80 | 11 | end |
81 | 12 |
|
| 13 | +function boot_print_stage(stage) |
| 14 | + if not SMODS.booted then |
| 15 | + boot_timer(nil, "STEAMODDED - " .. stage, 0.95) |
| 16 | + end |
| 17 | +end |
| 18 | + |
| 19 | +local catimg = NFS.getInfo(SMODS.path.."assets/cat.png") and love.graphics.newImage(love.filesystem.newFileData(NFS.read(SMODS.path.."assets/cat.png"))) |
| 20 | +function boot_timer(_label, _next, progress) |
| 21 | + progress = progress or 0 |
| 22 | + G.LOADING = G.LOADING or { |
| 23 | + font = love.graphics.setNewFont("resources/fonts/m6x11plus.ttf", 20), |
| 24 | + love.graphics.dis |
| 25 | + } |
| 26 | + local realw, realh = love.window.getMode() |
| 27 | + love.graphics.setCanvas() |
| 28 | + love.graphics.push() |
| 29 | + love.graphics.setShader() |
| 30 | + love.graphics.clear(0, 0, 0, 1) |
| 31 | + love.graphics.setColor(0.6, 0.8, 0.9, 1) |
| 32 | + if progress > 0 then love.graphics.rectangle('fill', realw / 2 - 150, realh / 2 - 15, progress * 300, 30, 5) end |
| 33 | + love.graphics.setColor(1, 1, 1, 1) |
| 34 | + love.graphics.setLineWidth(3) |
| 35 | + love.graphics.rectangle('line', realw / 2 - 150, realh / 2 - 15, 300, 30, 5) |
| 36 | + if catimg then love.graphics.draw(catimg, realw/2 - 264, realh/2 - 27, 0, 1, 1); love.graphics.rectangle('line', realw/2 - 264, realh/2 - 27, 96, 96, 5) end |
| 37 | + love.graphics.print("LOADING: " .. _next, realw / 2 - 150, realh / 2 + 40) |
| 38 | + love.graphics.pop() |
| 39 | + love.graphics.present() |
| 40 | + |
| 41 | + G.ARGS.bt = G.ARGS.bt or love.timer.getTime() |
| 42 | + G.ARGS.bt = love.timer.getTime() |
| 43 | +end |
82 | 44 | sendInfoMessage("Steamodded v" .. SMODS.version, "SMODS") |
| 45 | + |
0 commit comments