Skip to content

Commit

Permalink
Alpha 1.4
Browse files Browse the repository at this point in the history
  • Loading branch information
mwilsnd committed May 17, 2020
1 parent d93dd4f commit 5c999c1
Show file tree
Hide file tree
Showing 33 changed files with 2,135 additions and 295 deletions.
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,6 @@
[submodule "Deps/cereal"]
path = Deps/cereal
url = https://github.com/USCiLab/cereal.git
[submodule "Deps/json"]
path = Deps/json
url = https://github.com/nlohmann/json.git
17 changes: 17 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,20 @@
## Alpha 1.4
* Bumped module and MCM version number to 5
* Fixed the camera position not continuing to update while in other camera states like firstperson, causing a sudden jump when entering thirdperson.
* Added preset support with 6 save slots.
* Added a new smoothing option for transitioning between different side & up offsets.
* Added a new smoothing option for transitioning between different zoom levels.
* Added a new option to always use the 3D crosshair.
* Added a new option to grow the 3D crosshair by a set amount when intersecting with an NPC.
* Added new options to scale the crosshair based on ray-hit distance.
* Fixed choppy yaw rotation updates, most noticable when interpolation is disabled.
* Removed pitch singularity guards.
* Massive 3D crosshair improvements - much more accurate, basic ray-actor intersection (ray-AABB). Currently there are issues with AABB position and rotation with non-human NPCs and human NPCs which are not standing upright, but works for the most part. This is more of a hold-over for the moment until I can find a better raycasting method in the engine.
* Changed how the 3D crosshair works in the hudmenu, now using a separate crosshair object from the hud base instance, added new scaling methods. I'm now including the flash project (fla) due to these changes.
* Added a line and box drawing system for debug builds to help visualize ray casts and actor AABBs, toggled using the insert key.
* Switched to a different JSON library, new one should tolerate version upgrades much better.
* Tweaked some of the default config values.

## Alpha 1.3
* Bumped module and MCM version number to 4
* Fixed issue #11 causing the player to teleport when using Skyrim Souls RE and the HUD patch.
Expand Down
1 change: 1 addition & 0 deletions Deps/json
Submodule json added at 3799b3
Binary file modified MCM/SmoothCamMCM.pex
Binary file not shown.
246 changes: 241 additions & 5 deletions MCM/mcm.psc
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ Import SKSE
; This used to be way worse until I wrote the code generation tools

string[] interpMethods
string[] presets

Function SmoothCam_SetStringConfig(string member, string value) global native
Function SmoothCam_SetBoolConfig(string member, bool value) global native
Expand All @@ -13,6 +14,10 @@ string Function SmoothCam_GetStringConfig(string member) global native
bool Function SmoothCam_GetBoolConfig(string member) global native
float Function SmoothCam_GetFloatConfig(string member) global native

string Function SmoothCam_SaveAsPreset(int index, string name) global native
bool Function SmoothCam_LoadPreset(int index) global native
string Function SmoothCam_GetPresetNameAtIndex(int index) global native

int Function GetCurrentInterpIndex(string setting)
string value = SmoothCam_GetStringConfig(setting)

Expand Down Expand Up @@ -109,8 +114,116 @@ endFunction
}
}

#constexpr_struct SavePresetSetting {
real_int ref = 0
int presetIndex = 0
string displayName = ""
string desc = "Save your current settings to this preset slot"

MACRO implControl = {
this->ref = AddInputOption(this->displayName + " " + SmoothCam_GetPresetNameAtIndex(this->presetIndex), SmoothCam_GetPresetNameAtIndex(this->presetIndex))
}

MACRO implOpenHandler = {
string value = SmoothCam_GetPresetNameAtIndex(this->presetIndex)
if (value == "Empty")
SetInputDialogStartText("Enter a preset name")
else
SetInputDialogStartText(value)
endIf
}

MACRO implAcceptHandler = {
if (SmoothCam_SaveAsPreset(this->presetIndex, a_input) == "")
ShowMessage("Preset saved.", false)
else
ShowMessage("Failed to save preset!", false)
endIf
ForcePageReset()
}

MACRO implDesc = {
SetInfoText(this->desc)
}
}

#constexpr_struct LoadPresetSetting {
real_int ref = 0
int presetIndex = 0
string displayName = ""
string desc = "Load this preset"

MACRO implControl = {
this->ref = AddToggleOption(this->displayName + " " + SmoothCam_GetPresetNameAtIndex(this->presetIndex), false)
}

MACRO implSelectHandler = {
if (!SmoothCam_LoadPreset(this->presetIndex))
ShowMessage("Failed to load preset! Have you saved this slot yet?", false)
else
ShowMessage("Preset loaded.", false)
ForcePageReset()
endIf
}

MACRO implDesc = {
SetInfoText(this->desc)
}
}

ScriptMeta scriptMetaInfo -> {
version: 4
version: 5
}

; Presets
SavePresetSetting savePresetSlot1 -> {
presetIndex: 0
displayName: "Slot 1:"
}
SavePresetSetting savePresetSlot2 -> {
presetIndex: 1
displayName: "Slot 2:"
}
SavePresetSetting savePresetSlot3 -> {
presetIndex: 2
displayName: "Slot 3:"
}
SavePresetSetting savePresetSlot4 -> {
presetIndex: 3
displayName: "Slot 4:"
}
SavePresetSetting savePresetSlot5 -> {
presetIndex: 4
displayName: "Slot 5:"
}
SavePresetSetting savePresetSlot6 -> {
presetIndex: 5
displayName: "Slot 6:"
}

LoadPresetSetting loadPresetSlot1 -> {
presetIndex: 0
displayName: "Slot 1:"
}
LoadPresetSetting loadPresetSlot2 -> {
presetIndex: 1
displayName: "Slot 2:"
}
LoadPresetSetting loadPresetSlot3 -> {
presetIndex: 2
displayName: "Slot 3:"
}
LoadPresetSetting loadPresetSlot4 -> {
presetIndex: 3
displayName: "Slot 4:"
}
LoadPresetSetting loadPresetSlot5 -> {
presetIndex: 4
displayName: "Slot 5:"
}
LoadPresetSetting loadPresetSlot6 -> {
presetIndex: 5
displayName: "Slot 6:"
}

; Compat
Expand Down Expand Up @@ -151,6 +264,16 @@ ToggleSetting sepLocalInterpEnabled -> {
displayName: "Local-Space Interpolation Enabled"
desc: "Enable separate local-space camera smoothing (Camera rotation)."
}
ToggleSetting offsetInterpEnabled -> {
settingName: "OffsetTransitionEnabled"
displayName: "Offset Interpolation Enabled"
desc: "Enable smoothing of camera offset state transitions."
}
ToggleSetting zoomInterpEnabled -> {
settingName: "ZoomTransitionEnabled"
displayName: "Zoom Interpolation Enabled"
desc: "Enable smoothing of camera zoom state transitions."
}
ToggleSetting disableDeltaTime -> {
settingName: "DisableDeltaTime"
displayName: "Disable Delta Time Factoring"
Expand Down Expand Up @@ -187,6 +310,16 @@ ListSetting sepLocalInterpMethod -> {
displayName: "Local-Space Interpolation Method"
desc: "The scalar method to use for local-space smoothing (If enabled)."
}
ListSetting offsetInterpMethod -> {
settingName: "OffsetTransitionMethod"
displayName: "Offset Interpolation Method"
desc: "The scalar method to use for offset transition smoothing (If enabled)."
}
ListSetting zoomInterpMethod -> {
settingName: "ZoomTransitionMethod"
displayName: "Zoom Interpolation Method"
desc: "The scalar method to use for zoom transition smoothing (If enabled)."
}

SliderSetting minCameraFollowRate -> {
settingName: "MinCameraFollowRate"
Expand Down Expand Up @@ -266,6 +399,26 @@ SliderSetting maxSepZSmoothingDistance -> {
max: 300.0
displayFormat: "{0}"
}
SliderSetting offsetTransitionDuration -> {
settingName: "OffsetTransitionDuration"
displayName: "Offset Interpolation Duration"
desc: "The smoothing duration to use when the camera changes offsets (In seconds)."
defaultValue: 1.0
interval: 0.01
min: 0.01
max: 5.0
displayFormat: "{2}"
}
SliderSetting zoomTransitionDuration -> {
settingName: "ZoomTransitionDuration"
displayName: "Zoom Interpolation Duration"
desc: "The smoothing duration to use when the camera changes zoom distance (In seconds)."
defaultValue: 0.2
interval: 0.01
min: 0.01
max: 1.0
displayFormat: "{2}"
}
SliderSetting cameraDistanceClampXMin -> {
settingName: "CameraDistanceClampXMin"
displayName: "Distance Clamp X Min"
Expand Down Expand Up @@ -343,6 +496,11 @@ ToggleSetting crosshair3DEnabled -> {
displayName: "3D Crosshair Enabled"
desc: "Enable the raycasted 3D crosshair when in combat."
}
ToggleSetting alwaysUse3DCrosshair -> {
settingName: "AlwaysUse3DCrosshair"
displayName: "Always Use 3D Crosshair"
desc: "Always use the 3D crosshair, even when not in a combat stance."
}
ToggleSetting hideCrosshairOutOfCombat -> {
settingName: "HideCrosshairOutOfCombat"
displayName: "Hide Non-Combat Crosshair"
Expand All @@ -353,6 +511,33 @@ ToggleSetting hideCrosshairMeleeCombat -> {
displayName: "Hide Melee Combat Crosshair"
desc: "Hide the crosshair when in melee combat."
}
SliderSetting crosshairNPCGrowSize -> {
settingName: "CrosshairNPCGrowSize"
displayName: "NPC Hit Size"
desc: "When the 3D crosshair is over an NPC, grow the size of the crosshair by this amount."
defaultValue: 16
interval: 1
min: 0
max: 32
}
SliderSetting crosshairMinDistSize -> {
settingName: "CrosshairMinDistSize"
displayName: "Min Crosshair Size"
desc: "Sets the size of the 3D crosshair when the player's aim ray is at the maximum distance."
defaultValue: 16
interval: 1
min: 8
max: 32
}
SliderSetting crosshairMaxDistSize -> {
settingName: "CrosshairMaxDistSize"
displayName: "Max Crosshair Size"
desc: "Sets the size of the 3D crosshair when the player's aim ray is at the minimum distance."
defaultValue: 24
interval: 1
min: 8
max: 32
}

; Standing
SliderSetting standing_sideOffset -> {
Expand Down Expand Up @@ -842,7 +1027,7 @@ event OnConfigInit()
" Info", " Compatibility", " Following", " Crosshair", " Standing",
" Walking", " Running", " Sprinting", " Sneaking",
" Swimming", " Bow Aiming", " Sitting", " Horseback",
" Dragon"
" Dragon", " Presets"
}
interpMethods = new string[] -> {
"linear", "quadraticEaseIn", "quadraticEaseOut",
Expand Down Expand Up @@ -886,6 +1071,16 @@ event OnPageReset(string a_page)
sepLocalInterpEnabled, sepLocalInterpMethod, sepLocalSpaceInterpRate
})

AddHeaderOption("Offset Interpolation")
IMPL_STRUCT_MACRO_INVOKE_GROUP(implControl, {
offsetInterpEnabled, offsetInterpMethod, offsetTransitionDuration
})

AddHeaderOption("Zoom Interpolation")
IMPL_STRUCT_MACRO_INVOKE_GROUP(implControl, {
zoomInterpEnabled, zoomInterpMethod, zoomTransitionDuration
})

SetCursorPosition(1)
AddHeaderOption("Distance Clamping")
IMPL_STRUCT_MACRO_INVOKE_GROUP(implControl, {
Expand All @@ -899,8 +1094,15 @@ event OnPageReset(string a_page)
zoomMul, disableDeltaTime
})
elseIf (a_page == " Crosshair")
AddHeaderOption("3D Crosshair Settings")
IMPL_STRUCT_MACRO_INVOKE_GROUP(implControl, {
crosshair3DEnabled, hideCrosshairOutOfCombat, hideCrosshairMeleeCombat
crosshair3DEnabled, alwaysUse3DCrosshair, crosshairNPCGrowSize,
crosshairMinDistSize, crosshairMaxDistSize
})

AddHeaderOption("Crosshair Hiding")
IMPL_STRUCT_MACRO_INVOKE_GROUP(implControl, {
hideCrosshairOutOfCombat, hideCrosshairMeleeCombat,
})
elseIf (a_page == " Standing")
AddHeaderOption("Standing Offsets")
Expand Down Expand Up @@ -1052,11 +1254,35 @@ event OnPageReset(string a_page)
dragon_sideOffset,
dragon_upOffset
})
elseIf (a_page == " Presets")
AddHeaderOption("Save Preset")
IMPL_STRUCT_MACRO_INVOKE_GROUP(implControl, {
savePresetSlot1,
savePresetSlot2,
savePresetSlot3,
savePresetSlot4,
savePresetSlot5,
savePresetSlot6
})

SetCursorPosition(1)
AddHeaderOption("Load Preset")
IMPL_STRUCT_MACRO_INVOKE_GROUP(implControl, {
loadPresetSlot1,
loadPresetSlot2,
loadPresetSlot3,
loadPresetSlot4,
loadPresetSlot5,
loadPresetSlot6
})
endIf
endEvent

event OnOptionSelect(int a_option)
IMPL_IFCHAIN_MACRO_INVOKE(a_option, ref, implSelectHandler, {IMPL_ALL_IMPLS_OF_STRUCT(ToggleSetting)})
IMPL_IFCHAIN_MACRO_INVOKE(a_option, ref, implSelectHandler, {
IMPL_ALL_IMPLS_OF_STRUCT(ToggleSetting),
IMPL_ALL_IMPLS_OF_STRUCT(LoadPresetSetting)
})
endEvent

event OnOptionSliderOpen(int a_option)
Expand All @@ -1075,10 +1301,20 @@ event OnOptionMenuAccept(int a_option, int a_index)
IMPL_IFCHAIN_MACRO_INVOKE(a_option, ref, implAcceptHandler, {IMPL_ALL_IMPLS_OF_STRUCT(ListSetting)})
endEvent

event OnOptionInputOpen(int a_option)
IMPL_IFCHAIN_MACRO_INVOKE(a_option, ref, implOpenHandler, {IMPL_ALL_IMPLS_OF_STRUCT(SavePresetSetting)})
endEvent

event OnOptionInputAccept(int a_option, string a_input)
IMPL_IFCHAIN_MACRO_INVOKE(a_option, ref, implAcceptHandler, {IMPL_ALL_IMPLS_OF_STRUCT(SavePresetSetting)})
endEvent

event OnOptionHighlight(int a_option)
IMPL_IFCHAIN_MACRO_INVOKE(a_option, ref, implDesc, {
IMPL_ALL_IMPLS_OF_STRUCT(SliderSetting),
IMPL_ALL_IMPLS_OF_STRUCT(ToggleSetting),
IMPL_ALL_IMPLS_OF_STRUCT(ListSetting)
IMPL_ALL_IMPLS_OF_STRUCT(ListSetting),
IMPL_ALL_IMPLS_OF_STRUCT(SavePresetSetting),
IMPL_ALL_IMPLS_OF_STRUCT(LoadPresetSetting)
})
endEvent
3 changes: 3 additions & 0 deletions MCM/preproc/preproc_constexpr_struct.lua
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,9 @@ do class "ConstexprStructToVars" : namespace "papyrus.preproc" {
for indent, decl, member in self.m_strSource:gmatch("(%s*)([%a%d_]+)%->!([%a%d_]+)") do
if self.m_tblStructImpls[decl] and not self.m_tblStructMacroUsage[decl.. "->!".. member] then
local code = self.m_tblStructTypes[self.m_tblStructImpls[decl].type].macros[member]
if not code then
error("Missing code impl for macro ".. member.. " (decltype ".. decl.. ")")
end
code = code:replace( "this->", decl.."." )

indent = indent:gsub( "\n", "" )
Expand Down
Loading

0 comments on commit 5c999c1

Please sign in to comment.