Skip to content

Commit

Permalink
Properly remove only unused parts, fixes #1
Browse files Browse the repository at this point in the history
  • Loading branch information
SalatielSauer committed Sep 21, 2024
1 parent 308dc54 commit b94b2eb
Showing 1 changed file with 39 additions and 11 deletions.
50 changes: 39 additions & 11 deletions skincolorizer.cfg
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SkinColorizer Lite, by @SalatielSauer
// V: 15/09/2024
// V: 20/09/2024

setskincolorizerdir = [
_skcl_custom_dir = $arg2
Expand All @@ -25,10 +25,11 @@ skincolorizer = [
]

// path:packages/models/snoutx10k|part:Upper| = ...
//echo $path:packages/models/snoutx10k|part:Upper| // [[r g b] texture]
//echo $path:packages/models/snoutx10k|part:Upper| // [[r g b] texture selected fullbright]

model_alias = (concatword "_skincolorizer_path:" $model_path "|part:" (strreplace $arg2 " " "~") "|")


if (= (indexof $_skcl_all_model_aliases_temp $model_alias) -1) [
//echo (concat "^f3" $_skcl_custom_dir "^f1" $model_path ":" $arg1 "|" $arg2 "|" $arg3 "|" $arg4 "|" $arg5 "|" $arg6)
// brute force
Expand All @@ -38,19 +39,22 @@ skincolorizer = [
]
if (! (findfile (concatword $texture_path "/" $arg3))) [
echo (concatword "^f7skincolorizer: ^f3could not find texture " $model_path "/^f2" $arg3)
echo (concatword "^f7SkinColorizer Lite: ^f3could not find texture " $model_path "/^f2" $arg3)
] [
//echo (concatword "^f0found texture at " $texture_path "/^f8" $arg3)
]
// texture [r g b] selected fullbright
// [r g b] texture selected fullbright
$model_alias = (format "%1 %2/%3 0 0" "[1 1 1]" $texture_path $arg3)
append _skcl_all_model_aliases_temp $model_alias
] [
if (=s (getalias $model_alias) "") [
// the part is included but has not been initialized
echo (concat "^f7SkinColorizer Lite: restoring part settings for:" @arg2)
$model_alias = (format "%1 %2/%3 0 0" "[1 1 1]" $texture_path $arg3)
]
]
//echo $model_alias == $$model_alias
do [
//echo (format "colors: %1 | %2 | %3" @(at $$model_alias 0))
@arg1 $arg2 (format "<mad:%1/%2/%3>%4" @(at $$model_alias 0) $arg3) $arg4 $arg5 $arg6
Expand Down Expand Up @@ -400,8 +404,6 @@ if (=s (getalias _skcl_all_model_aliases) "") [
_skcl_all_model_aliases_temp = []
_skcl_preloaded_models = []
_skcl_preloaded_models_temp = []
_skcl_reset_models_onrestart = 2
_skcl_gui_list_height = 5
] [
if (listlen $_skcl_all_model_aliases) [
// keep all parts
Expand All @@ -414,29 +416,55 @@ if (=s (getalias _skcl_all_model_aliases) "") [
if (= $_skcl_reset_models_onrestart 1) [
_skcl_all_model_aliases_temp = []
_skcl_preloaded_models_temp = []
// purge unused aliases on exit
looplist model_alias $_skcl_all_model_aliases [
$model_alias = []
]
_skcl_all_model_aliases = []
_skcl_preloaded_models = []
]
// keep modified parts
if (= $_skcl_reset_models_onrestart 2) [
_skcl_all_model_aliases_temp = (listfilter model_alias $_skcl_all_model_aliases [|| (!=s (strreplace (at $$model_alias 0) ".0" "") "1 1 1") (!= (at $$model_alias 2) 0)])
local is_unused
// checks color / selection / fullbright
is_unused = [&& (=s (strreplace (at $arg1 0) ".0" "") "1 1 1") (= (at $arg1 2) 0) (= (at $arg1 3) 0)]
_skcl_all_model_aliases_temp = (listfilter model_alias $_skcl_all_model_aliases [! (is_unused $$model_alias)])
_skcl_preloaded_models_temp = (looplistconcat model_alias $_skcl_all_model_aliases_temp [strreplace (_getinlineattr $model_alias "path") "packages/models/" ""])
// purge unused aliases on exit
looplist unused_alias (listfilter model_alias $_skcl_all_model_aliases [is_unused $$model_alias]) [
$unused_alias = []
]
_skcl_all_model_aliases = $_skcl_all_model_aliases_temp
_skcl_preloaded_models = $_skcl_preloaded_models_temp
]
local current previous
current = (listlen $_skcl_all_model_aliases_temp)
previous = (listlen $_skcl_all_model_aliases)
previous = (listlen @_skcl_all_model_aliases)
if (!= $current 0) [
echo (format "^f7SkinColorizer Lite: ^f0%1 ^f7parts%2loaded successfully" $current (? (> $previous $current) (concatword " ^f7(^f3-" (- $previous $current) "^f7) ") " "))
]
]
]
if (=s (getalias _skcl_reset_models_onrestart) "") [
_skcl_reset_models_onrestart = 2
_skcl_gui_list_height = 5
]
_skcl_gui_white = "packages/skyboxes/white_dn.jpg"
_skcl_custom_dir = ""
_skcl_preview_team = 0
_skcl_selection_counter = 0
_skcl_selection_last = ""
_skcl_selection_search = ""
_curtabmodel_alias = 0 // guilistscroll slider
_skcl_gui_settings = [
newgui _skcl_settings [guistayopen [
Expand Down

0 comments on commit b94b2eb

Please sign in to comment.