Skip to content
This repository has been archived by the owner on Sep 29, 2023. It is now read-only.

Commit

Permalink
Merge pull request #115 from Specnr/dev
Browse files Browse the repository at this point in the history
bug fix & cleanup
  • Loading branch information
Specnr committed Mar 16, 2023
2 parents 0bfb4e3 + 67bbfe7 commit 7c44ec4
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 34 deletions.
2 changes: 1 addition & 1 deletion TheWall.ahk
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Thread, NoTimers , True
SetKeyDelay, 0
SetWinDelay, 1
SetTitleMatchMode, 2
SendLog(LOG_LEVEL_INFO, "Starting MultiResetWall v1.1.1")
SendLog(LOG_LEVEL_INFO, "Starting MultiResetWall v1.1.2")

; Yell if wrong AHK version
if (SubStr(A_AhkVersion, 1, 3) != "1.1") {
Expand Down
10 changes: 8 additions & 2 deletions scripts/functions.ahk
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ GetOldestPreview() {
}

ReplacePreviewsInGrid() {
if (mode != "I")
return
if (GetPassiveGridInstanceCount() == 0)
return
gridUsageCount := GetFocusGridInstanceCount()
hasSwapped := False
loop %gridUsageCount% {
Expand Down Expand Up @@ -536,8 +540,10 @@ ResetInstance(idx, bypassLock:=true, extraProt:=0, resettingAll:=false) {
spawnProt := spawnProtection + extraProt
if (idx > 0 && idx <= instances && !FileExist(holdFile) && (spawnProt + previewTime) < A_TickCount && ((!bypassLock && !locked[idx]) || bypassLock)) {
if (mode == "I") {
if (!locked[idx])
SwapPositions(GetGridIndexFromInstanceNumber(idx), GetOldestInstanceIndexOutsideGrid())
if (!locked[idx]) {
if (GetPassiveGridInstanceCount() > 0)
SwapPositions(GetGridIndexFromInstanceNumber(idx), GetOldestInstanceIndexOutsideGrid())
}
else {
gridUsageCount := GetFocusGridInstanceCount()
if (gridUsageCount < rxc)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
lastUpdate = 0.0
screen_width = 0
screen_height = 0
version = "v1.1.0"
version = "v1.1.2"
path = os.path.dirname(os.path.realpath(__file__))
reloadPath = os.path.abspath(os.path.realpath(
os.path.join(path, '..', 'data', 'macro.reload')))
Expand Down Expand Up @@ -109,23 +109,24 @@ def manage_movement():
get_setting_from_ahk("pixelsBetweenInstances"))
os.remove(reloadPath)

wall_scene = S.obs_get_scene_by_name(wall_scene_name)
if screen_height == 0:
wall_scene = S.obs_scene_get_source(
S.obs_get_scene_by_name(wall_scene_name))
screen_width = S.obs_source_get_width(wall_scene)
screen_height = S.obs_source_get_height(wall_scene)
S.obs_source_release(wall_scene)
wall_scene_source = S.obs_scene_get_source(wall_scene)
screen_width = S.obs_source_get_width(wall_scene_source)
screen_height = S.obs_source_get_height(wall_scene_source)

wall_scene = S.obs_get_scene_by_name(wall_scene_name)
if not wall_scene:
print("Can't find scene")
S.obs_scene_release(wall_scene)
return

if not os.path.exists(obstxtPath):
print("Can't find obs.txt")
S.obs_scene_release(wall_scene)
return
currentTime = os.path.getmtime(obstxtPath)
if currentTime == lastUpdate:
S.obs_scene_release(wall_scene)
return
lastUpdate = currentTime

Expand Down Expand Up @@ -192,6 +193,7 @@ def manage_movement():
focus_cols), row * (screen_height * screen_estate_vertical / focus_rows))
scale_source(scene_item, screen_width * screen_estate_horizontal /
focus_cols - pX, screen_height * screen_estate_vertical / focus_rows - pY)
S.obs_scene_release(wall_scene)
prev_instances = instances
prev_passive_count = passive_count
prev_locked_count = locked_count
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@
wall_scene_name = "The Wall"
instance_scene_format = "Instance *"
lock_format = "lock *"
version = "v1.1.0"
cover_format = "cover *"
mc_format = "mc *"
version = "v1.1.2"


logging.basicConfig(
Expand Down Expand Up @@ -48,34 +50,45 @@ def get_cmd(path):
return cmd


def handle_wall():
wall_scene = S.obs_get_scene_by_name(wall_scene_name)
wall_scene_source = S.obs_scene_get_source(wall_scene)
S.obs_scene_release(wall_scene)
S.obs_frontend_set_current_scene(wall_scene_source)


def handle_play(inst):
instance_name = instance_scene_format.replace("*", str(inst))
instance_scene = S.obs_get_scene_by_name(instance_name)
instance_scene_source = S.obs_scene_get_source(instance_scene)
S.obs_scene_release(instance_scene)
if not instance_scene_source:
print(
f"Could not find instance scene '{instance_name}', make sure they are in the format 'Instance *'")
S.obs_frontend_set_current_scene(instance_scene_source)


def handle_lock(render, inst):
wall_scene = S.obs_get_scene_by_name(wall_scene_name)
lock_name = lock_format.replace("*", str(inst))
lock_source = S.obs_scene_find_source_recursive(
wall_scene, lock_name)
if not lock_source:
print(
f"Could not find lock source '{lock_name}', make sure they are in the format 'lock *'")
S.obs_sceneitem_set_visible(lock_source, render)
S.obs_scene_release(wall_scene)


def execute_cmd(cmd):
try:
if (cmd[0] == "ToWall"):
wall_scene = S.obs_scene_get_source(
S.obs_get_scene_by_name(wall_scene_name))
S.obs_frontend_set_current_scene(wall_scene)
S.obs_source_release(wall_scene)
handle_wall()
elif (cmd[0] == "Play"):
inst_num = cmd[1]
instance_name = instance_scene_format.replace("*", str(inst_num))
instance_scene = S.obs_scene_get_source(
S.obs_get_scene_by_name(instance_name))
if not instance_scene:
print(
f"Could not find instance scene '{instance_name}', make sure they are in the format 'Instance *'")
S.obs_frontend_set_current_scene(instance_scene)
handle_play(cmd[1])
elif (cmd[0] == "Lock"):
lock_num = cmd[1]
render = cmd[2] == "1"
wall_scene = S.obs_scene_get_source(
S.obs_get_scene_by_name(wall_scene_name))
lock_name = lock_format.replace("*", str(lock_num))
lock_source = S.obs_scene_find_source_recursive(S.obs_scene_from_source(
wall_scene), lock_name)
if not lock_source:
print(
f"Could not find lock source '{lock_name}', make sure they are in the format 'lock *'")
S.obs_sceneitem_set_visible(lock_source, render)
handle_lock(cmd[2] == "1", cmd[1])

except Exception as e:
print(f"Error: {e}")
logging.error(e)
Expand Down

0 comments on commit 7c44ec4

Please sign in to comment.