Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Better head pics of kids, Hide UI , Option NonNude #19

Merged
merged 4 commits into from
Dec 28, 2022
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
# Compiled scripts
Data/Scripts

Muriel-Salvan marked this conversation as resolved.
Show resolved Hide resolved

# Packaged artefact
AutoTest.7z

# Generated README for NexusMods
README.bbcode
build.cmd
Muriel-Salvan marked this conversation as resolved.
Show resolved Hide resolved
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
# 1.2.0

## Features

* [NPCs] Added option to take NPC full body screen shots with default outfits.
* [NPCsHead] Added some scripting to take better headshots of child NPCs.
* [NPCsHead] [NPCs] Hide UI while taking screenshots.
* [NPCsHead] [NPCs] Added code to make sure player is in 1stPerson View.

# 1.1.0

## Features
Expand Down
30 changes: 30 additions & 0 deletions Data/Scripts/AutoTest_InGameMenu.psc
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
Scriptname AutoTest_InGameMenu extends ObjectReference
{
Small script adding some testing UI to an activator.
Useless for the automatic tests run.
Dependencies:
* SkyUILib for the menu interface (https://www.nexusmods.com/skyrim/mods/57308)
}

; Quest containing all ReferenceAlias for each test script
Quest Property QuestScriptsContainer Auto

Event OnActivate(ObjectReference akActionRef)
String[] sOptions = new String[4]
sOptions[0] = "Register tests"
sOptions[1] = "Run tests"
sOptions[2] = "Clear tests statuses"
sOptions[3] = "Exit"
int iInput = ((Self as Form) as UILIB_1).ShowList("Integration testing", sOptions, 0, 0)
if iInput == 0
AutoTest_TestsRunner.InitTests(QuestScriptsContainer)
AutoTest_TestsRunner.RegisterTests(QuestScriptsContainer)
elseif iInput == 1
AutoTest_TestsRunner.StartTestsSession()
AutoTest_TestsRunner.InitTests(QuestScriptsContainer)
AutoTest_TestsRunner.RunTests(QuestScriptsContainer)
elseif iInput == 2
AutoTest_TestsRunner.InitTests(QuestScriptsContainer)
AutoTest_TestsRunner.ClearTestsStatuses(QuestScriptsContainer)
endIf
endEvent
18 changes: 18 additions & 0 deletions Data/Scripts/AutoTest_Log.psc
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
Scriptname AutoTest_Log extends ObjectReference
{
Simple log helpers, used by other scripts.
}

; Init logs
function InitLog() global
Debug.OpenUserLog("AutoTest")
endFunction

; Log a message, both on screen and on file
;
; Parameters::
; * *msg* (string): The message to log
function Log(string msg) global
Debug.TraceUser("AutoTest", msg)
Debug.Notification(msg)
endFunction
8 changes: 8 additions & 0 deletions Data/Scripts/AutoTest_OnLoadAliasScript.psc
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
ScriptName AutoTest_OnLoadAliasScript extends ReferenceAlias

AutoTest_OnLoadQuestScript Property QuestScript Auto
Quest Property QuestScriptsContainer Auto

Event OnPlayerLoadGame()
QuestScript.InitializeAutoTest(QuestScriptsContainer)
EndEvent
99 changes: 99 additions & 0 deletions Data/Scripts/AutoTest_OnLoadQuestScript.psc
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
ScriptName AutoTest_OnLoadQuestScript extends Quest
{
Note: Big thanks to milzschnitte who posted the technique to call Papyrus scripts from the console: https://www.loverslab.com/topic/58600-skyrim-custom-console-commands-using-papyrus/
}

; Quest containing all ReferenceAlias for each test script
Quest Property QuestScriptsContainer Auto

; OnPlayerLoadGame will not fire the first time
Event OnInit()
InitializeAutoTest(QuestScriptsContainer)
EndEvent

; Initialize AutoTest.
; This is called on game load.
; Handle continuity in testing after a CTD.
;
; Parameters::
; * *questScript* (Quest): The quest containing test scripts
Function InitializeAutoTest(Quest questScript)
AutoTest_Log.InitLog()
UnregisterForMenu("Console")
RegisterForMenu("Console")
; If we are in a tests session, resume it.
if AutoTest_TestsRunner.InTestsSession()
AutoTest_Log.Log("Resuming previous tests session")
; Automatically resume tests.
; The session was already started.
AutoTest_TestsRunner.InitTests(questScript)
AutoTest_TestsRunner.RunTests(questScript)
elseif JsonUtil.GetStringValue("AutoTest_Config.json", "on_start") == "run"
AutoTest_Log.Log("Starting tests session from the game load")
; We have to start testing
AutoTest_TestsRunner.StartTestsSession()
AutoTest_TestsRunner.InitTests(questScript)
AutoTest_TestsRunner.RunTests(questScript)
endIf
EndFunction

Event OnMenuOpen(string menuName)
if menuName=="Console"
RegisterForKey(28)
RegisterForKey(156)
endif
endEvent

Event OnMenuClose(string menuName)
if menuName=="Console"
UnregisterForKey(28)
UnregisterForKey(156)
endif
endEvent

Event OnKeyDown(int keyCode)
if keyCode == 28 || keyCode == 156
int cmdCount = UI.GetInt("Console", "_global.Console.ConsoleInstance.Commands.length")
if cmdCount > 0
cmdCount -= 1
string cmdLine = UI.GetString("Console", "_global.Console.ConsoleInstance.Commands." + cmdCount)
if cmdLine != ""
bool bSuccess = false
actor a = Game.GetCurrentConsoleRef() as actor
if a == None
a = Game.GetPlayer()
endif
string[] cmd = StringUtil.Split(cmdLine, " ")
; Handle all possible commands we want to use
if cmd[0] == "start_tests"
AutoTest_Log.Log("User issued start_tests")
AutoTest_TestsRunner.StartTestsSession()
AutoTest_TestsRunner.InitTests(QuestScriptsContainer)
AutoTest_TestsRunner.RunTests(QuestScriptsContainer)
bSuccess = true
elseif cmd[0] == "stop_tests"
AutoTest_Log.Log("User issued stop_tests")
JsonUtil.SetStringValue("AutoTest_Config.json", "stopped_by", "user")
AutoTest_TestsRunner.EndTestsSession()
bSuccess = true
endif
; Remove error messages if we handled the command
if bSuccess == true
; Remove last line (error line)
Utility.WaitMenuMode(0.1)
string history = UI.GetString("Console", "_global.Console.ConsoleInstance.CommandHistory.text")
int iHistory = StringUtil.GetLength(history) - 1
bool bRunning = true
while iHistory > 0 && bRunning
if StringUtil.AsOrd(StringUtil.GetNthChar(history, iHistory - 1)) == 13
bRunning = false
else
iHistory -= 1
endif
endWhile
UI.SetString("Console", "_global.Console.ConsoleInstance.CommandHistory.text", StringUtil.Substring(history,0,iHistory))
endif
endif
endif
endif
endEvent
216 changes: 216 additions & 0 deletions Data/Scripts/AutoTest_Suite.psc
Original file line number Diff line number Diff line change
@@ -0,0 +1,216 @@
Scriptname AutoTest_Suite extends ReferenceAlias
{
Common interface of any script implementing integration testing.
Helpers to access the test database, stored in JSON files.
Dependencies:
* PapyrusUtils for JsonUtil (https://www.nexusmods.com/skyrimspecialedition/mods/13048)
}

string gTestType = "Unknown"
string gJSONRunFile = "AutoTest_Unknown_Run.json"
string gJSONStatusesFile = "AutoTest_Unknown_Statuses.json"
string gJSONconfigFile = "AutoTest_Unknown_Config.json"
bool gInsideTransaction = false

; Initialize the script
; [API] This function is mandatory and has to use SetTestType
function InitTests()
; To be overriden
endFunction

; Register tests
; [API] This function is mandatory
function RegisterTests()
; To be overriden
endFunction

; Prepare the runs of tests
; [API] This function is optional
function BeforeTestsRun()
; To be overriden
endFunction

; Run a given registered test.
; Set the status in this method.
; [API] This function is mandatory
;
; Parameters::
; * *testName* (string): The test name to run
function RunTest(string testName)
; To be overriden
endFunction

; Finalize the runs of tests
; [API] This function is optional
function AfterTestsRun()
; To be overriden
endFunction

; Log a message
;
; Parameters::
; * *msg* (string): Message to log
function Log(string msg)
AutoTest_Log.Log("[ " + gTestType + " ] - " + msg)
endFunction

; Set the test type
;
; Parameters::
; * *testType* (string): The test type
function SetTestType(string testType)
gTestType = testType
gJSONRunFile = "AutoTest_" + gTestType + "_Run.json"
gJSONStatusesFile = "AutoTest_" + gTestType + "_Statuses.json"
gJSONConfigFile = "AutoTest_" + gTestType + "_Config.json"
endFunction

; Get the test type
;
; Result::
; * string: The test type
string function GetTestType()
return gTestType
endFunction

; Set a test status in the JSON db
;
; Parameters::
; * *testName* (string): The test name
; * *testStatus* (string): The test status
function SetTestStatus(string testName, string testStatus)
JsonUtil.SetStringValue(gJSONStatusesFile, testName, testStatus)
SaveDb()
endFunction

; Get a test status in the JSON db
;
; Parameters::
; * *testName* (string): The test name
; Result::
; * string: The test status
string function GetTestStatus(string testName)
return JsonUtil.GetStringValue(gJSONStatusesFile, testName)
endFunction

; Get a config value from the JSON config file
;
; Parameters::
; * *configName* (string): The config name
; Result::
; * string: The config value
string function GetConfig(string configName)
return JsonUtil.GetStringValue(gJSONConfigFile, configName)
endFunction

; Get the number of registered tests
;
; Result::
; * int: The number of registered tests
int function NbrRegisteredTests()
return JsonUtil.StringListCount(gJSONRunFile, "tests_to_run")
endFunction

; Get the test name that has been registered at a given index
;
; Parameters::
; * *testIdx* (int): The registered test index
; Result::
; * string: The test name
string function GetTestName(int testIdx)
return JsonUtil.StringListGet(gJSONRunFile, "tests_to_run", testIdx)
endFunction

; Register a new test
;
; Parameters::
; * *testName* (string): The test name
function RegisterNewTest(string testName)
int nbrTests = JsonUtil.StringListAdd(gJSONRunFile, "tests_to_run", testName)
if nbrTests % 5000 == 0
; Small progression display
AutoTest_Log.Log("Number of " + gTestType + " tests registered: " + nbrTests)
endIf
endFunction

; Save the JSON Db on disk
;
; Parameters::
; * *forceSave* (bool): Do we force save? If false, then don't save if we are in a transaction [default = false]
function SaveDb(bool forceSave = false)
if forceSave || !gInsideTransaction
JsonUtil.Save(gJSONStatusesFile)
JsonUtil.Save(gJSONRunFile)
endIf
endFunction

; Start a transaction that might modify the JSON database.
function BeginDbTransaction()
gInsideTransaction = true
endFunction

; End a transaction that might have modified the JSON database.
function EndDbTransaction()
SaveDb(true)
gInsideTransaction = false
endFunction

; Clear registered tests
function ClearRegisteredTests()
JsonUtil.StringListClear(gJSONRunFile, "tests_to_run")
SaveDb()
endFunction

; Convert a String storing a hex number into an int
;
; Parameters::
; * *hexString* (string): The hexadecimal string
; Result::
; * int: The corresponding number
int function HexToInt(string hexString)
int result = 0
int strLength = StringUtil.GetLength(hexString)
int idx = 0
while (idx < strLength)
string currentDigit = StringUtil.GetNthChar(hexString, idx)
int currentValue
if (currentDigit == "1")
currentValue = 1
elseIf (currentDigit == "2")
currentValue = 2
elseIf (currentDigit == "3")
currentValue = 3
elseIf (currentDigit == "4")
currentValue = 4
elseIf (currentDigit == "5")
currentValue = 5
elseIf (currentDigit == "6")
currentValue = 6
elseIf (currentDigit == "7")
currentValue = 7
elseIf (currentDigit == "8")
currentValue = 8
elseIf (currentDigit == "9")
currentValue = 9
elseIf (currentDigit == "A")
currentValue = 10
elseIf (currentDigit == "B")
currentValue = 11
elseIf (currentDigit == "C")
currentValue = 12
elseIf (currentDigit == "D")
currentValue = 13
elseIf (currentDigit == "E")
currentValue = 14
elseIf (currentDigit == "F")
currentValue = 15
else
currentValue = 0
endIf
if currentValue > 0
result += Math.LeftShift(currentValue, 4 * (strLength - idx - 1))
endIf
idx += 1
endWhile
return result
endFunction
Loading