Finished settings
This commit is contained in:
@@ -256,6 +256,14 @@ class optimizer
|
||||
}
|
||||
}
|
||||
|
||||
public static function repack_all(osu_library $library) : void
|
||||
{
|
||||
foreach ($library->get_library() as $key => $mapset)
|
||||
{
|
||||
self::repack($library, $mapset["key"]);
|
||||
}
|
||||
}
|
||||
|
||||
public static function repack(osu_library $library, string $key) : string
|
||||
{
|
||||
$path = $library->get_library()[$key]["path"] ?? "";
|
||||
|
||||
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
class optimizer_settings
|
||||
{
|
||||
public $path;
|
||||
|
||||
private $osu_path = "";
|
||||
|
||||
public function __construct(string $path)
|
||||
{
|
||||
$this->path = $path;
|
||||
if (file_exists($path))
|
||||
{
|
||||
$this->load();
|
||||
}
|
||||
}
|
||||
|
||||
public function load()
|
||||
{
|
||||
$raw = file_get_contents($this->path);
|
||||
$json = json_decode($raw, true);
|
||||
|
||||
$this->osu_path = $json["osu_folder"] ?? "";
|
||||
}
|
||||
|
||||
public function save()
|
||||
{
|
||||
$json = array();
|
||||
$json["osu_path"] = $this->osu_path;
|
||||
|
||||
$raw = json_encode($json);
|
||||
file_put_contents($this->path);
|
||||
}
|
||||
|
||||
public function set_osu_path($path) : void
|
||||
{
|
||||
$sanitized = str_replace("\\", "/", $path);
|
||||
$sanitized = rtrim($sanitized, "/");
|
||||
if (file_exists($path))
|
||||
{
|
||||
$this->osu_path = $sanitized;
|
||||
}
|
||||
}
|
||||
|
||||
public function get_osu_path() : string
|
||||
{
|
||||
return $this->osu_path;
|
||||
}
|
||||
}
|
||||
@@ -178,7 +178,7 @@ class osu_library
|
||||
|
||||
public function get_root() : string
|
||||
{
|
||||
return $this->db["root"];
|
||||
return $this->db["root"] ?? "";
|
||||
}
|
||||
|
||||
public function set_root(string $root) : void
|
||||
|
||||
Reference in New Issue
Block a user